VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
void AVR.Core.AVR_GenericXRDevice.UpdateTracking ( )
inlineprotected

Updates the controller position and rotation.

Definition at line 92 of file AVR_GenericXRDevice.cs.

93  {
94  if (inputDevice.TryGetFeatureValue(CommonUsages.trackingState, out var trackingState))
95  {
96  if ((trackingState & InputTrackingState.Position) != 0 && inputDevice.TryGetFeatureValue(CommonUsages.devicePosition, out var devicePosition))
97  {
98  if (smoothing)
99  {
100  transform.localPosition = Vector3.Lerp(transform.localPosition, devicePosition, Time.deltaTime * smoothingFidelity * 90.0f);
101  }
102  else
103  {
104  transform.localPosition = devicePosition;
105  }
106  }
107 
108  if ((trackingState & InputTrackingState.Rotation) != 0 && inputDevice.TryGetFeatureValue(CommonUsages.deviceRotation, out var deviceRotation))
109  {
110  if (smoothing)
111  {
112  transform.localRotation = Quaternion.Lerp(transform.localRotation, deviceRotation, Time.deltaTime * smoothingFidelity * 90.0f);
113  }
114  else
115  {
116  transform.localRotation = deviceRotation;
117  }
118  }
119  }
120  }
InputDevice inputDevice
XR.Inputdevice that this controller represents.
float smoothingFidelity
Defines the amount of smoothing.
bool smoothing
Defines if positional tracking is smoothed across several frames. Makes controllers less shaky...