Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
JohnDe's avatar
JohnDe
Honored Guest
11 years ago

Set Rotation in Unity with OVR 5.0.1

Hello,

i was reading a lot of posts but i cannot find a way to set the orientation of the oculus. I have an avatar with the following structure:
Avatar
+ ...
+ OVRCameraRig
| + TrackingSpace
| + LeftEyeAnchor
| + CenterEyeAnchor
| + ...
+ neck
+ oculusPosition

The neck follows always the CenterEyeAnchor of the OVRCameraRig and the OVRCameraRig gets the position of oculusPosition.
Unfortunately OVRManager.display.RecenterPose() sets the yaw rotation only. I've tried to take the difference of the new rotation and CenterEyeAnchor rotation and added it to the OVRCameraRig. But sometimes the rotation error gots bigger and bigger.

Here a short code snippet:

void LateUpdate()
{
neck.rotation = centerEyeAnchor.rotation * oculusInNeckRot;
ovrCameraRig.position = oculusPosition.position;
}

void SetRotation(Quaternion newRotation)
{
ovrCameraRig.rotation *= Quaternion.Inverse(centerEyeAnchor.rotation) * newRotation;
}


Somebody has an idea what i'm doing wrong?
What is the right way to set the rotation?

Thanks!

1 Reply

  • JohnDe's avatar
    JohnDe
    Honored Guest
    For those with the same problem, i've found a way to fix it:

    void LateUpdate()
    {
    neck.rotation = centerEyeAnchor.rotation * oculusInNeckRot;
    ovrCameraRig.position = oculusPosition.position;
    }

    void SetRotation(Quaternion newRotation)
    {
    ovrCameraRig.rotation = newRotation * Quaternion.Inverse(leftEyeAnchor.rotation) * ovrCameraRig.rotation;
    }

    It seems to be important to take the LeftEyeAnchor instead of the CenterEyeAnchor.

    Regards!