- Home /
GearVR rotation stutter InputTracking.GetNodeStates
What is the correct way to use UnityEngine.VR.InputTracking.GetNodeStates()? Should this be called in Update, FixedUpdate or somewhere else?
I'm noticing a particualr problem on GearVR (not apparent on Rift) when updating my 'centerEyeCamera' position and rotation using the above, 'manual' method rather than relying on the 'automatic' built-in Unity tracking - I get a noticeable lag/stutter when rotating.
I have a scene where the user can switch between the auto-tracked camera and my 'manual' camera (where I set the position and rotation to the values I receive in GetNodeStates). The auto-tracked camera is significantly smoother than my 'manually' tracked one, but I would expect Unity to get those values from exactly the same place.
The code below is how I am updating my 'manual' camera transform - I have attempted to call this from Update, FixedUpdate and both at the same time, but each suffers from the same judder effect. I am disabling the 'automatic' tracking on the camera using VRDevice.DisableAutoVRCameraTracking(, true);
void UpdateNode()
{
InputTracking.GetNodeStates(nodeStates);
for (int i = 0; i < nodeStates.Count; ++i)
{
if (nodeStates[i].nodeType == VRNode.CenterEye)
{
Vector3 position;
if (nodeStates[i].TryGetPosition(out position))
centerEyeCam.transform.localPosition = position;
Quaternion rotation;
if (nodeStates[i].TryGetRotation(out rotation))
centerEyeCam.transform.localRotation = rotation;
}
}
}
Answer by DAVcoHL · Sep 08, 2017 at 11:01 AM
After much head scratching, I've found that the correct way to get smooth tracking while 'manually' setting position/rotation is to update the transform of the camera in the OnPreRender callback.
I'm guessing that the tracked eye position is updated in a much faster loop that Unity's render/physics update and has changed between the last Update and Render call, resulting in image stutter. So the only way to get a transform that matches the rendered image is to update the transform at the last possible moment.