Forum Discussion

rosss_mop's avatar
rosss_mop
Honored Guest
9 years ago
Solved

OVRCameraRig - eye positions is different in GearVR to in Unity Editor

I have an OVRCamearRIg (from the prefab) in my Unity Scene.. when i build and run the project on my Android Gear VR - the camera position... i.e. the player's head position is noticably lower than in ...
  • bkane's avatar
    9 years ago
    We just ran into this today using Unity 5.4.2p4 and Oculus Utilities 1.9.0. It looks like there's some old code in OVRCameraRig.cs to work around a Unity bug that no longer applies. The workaround lowers the camera by a fair bit and I believe should be removed:

    	private void Update()
    {
    EnsureGameObjectIntegrity();

    if (!Application.isPlaying)
    return;

    UpdateAnchors();

    #if UNITY_ANDROID && !UNITY_EDITOR

    if (!correctedTrackingSpace)
    {
    //HACK: Unity 5.1.1p3 double-counts the head model on Android. Subtract it off in the reference frame.

    var headModel = new Vector3(0f, OVRManager.profile.eyeHeight - OVRManager.profile.neckHeight, OVRManager.profile.eyeDepth);
    var eyePos = -headModel + centerEyeAnchor.localRotation * headModel;

    if ((eyePos - centerEyeAnchor.localPosition).magnitude > 0.01f)
    {
    trackingSpace.localPosition = trackingSpace.localPosition - 2f * (trackingSpace.localRotation * headModel);
    correctedTrackingSpace = true;
    }
    }
    #endif
    }
    Lines 119-134 should probably be removed from Oculus Utilities altogether. By default this was in a folded region of "#region Unity Messages" so it's easy to miss.
  • drash's avatar
    9 years ago
    Thanks bkane, this was very helpful!