void Update() { if (!useOptitrack) { this.transform.localPosition = new Vector3(0, 0, 0); if (!m_initialPoseSet) { m_initialPoseSet = true; m_fusion.setCurrentOrientation(this.transform.localRotation); } return; } OptitrackRigidBodyState rbState = StreamingClient.GetLatestRigidBodyState(RigidBodyId); if (rbState != null && rbState.DeliveryTimestamp.AgeSeconds < 1.0f) { Debug.Log("new position", this); // Update position. this.transform.localPosition = rbState.Pose.Position; // Update drift correction. if (m_lastTimestamp.AgeSeconds != rbState.DeliveryTimestamp.AgeSeconds) { // If we're coming here the first time: reset to optical pose. Otherwise // we're using the optical orientation for drift correction. if (!m_initialPoseSet) { m_initialPoseSet = true; m_fusion.setCurrentYaw(rbState.Pose.Orientation); } else if (enableDriftCorrection) { m_fusion.setCurrentYawSoft(rbState.Pose.Orientation); } m_lastTimestamp = rbState.DeliveryTimestamp; } } }