Skip to main content
Inspiring
February 4, 2016

Unity 5.3 OVR bad rotation init

I'm a developer for Unity+VR, both Oculus DK2 and GearVR and I use Oculus Utilities v0.1.3.

I've noticed a strage Issue switching from Unity 5.2.2p4 to Unity 5.3.2.p1: Virtual reality initializes/resets at the beginning of the programs in a strange manner. The issue is clearly visible with my GearVR innovator edition (Note 4 version): if I start a program builded with this Version of Unity with the head all tilted, the world will result all strangely inclined. With DK2 I also have some strange behaviour with my particular program, but I can't say you how to replicate this.
We made the tests using 2 GearVR with 2 Note4 and the results are the same. Building with Unity 5.1.x or 5.2.x solves the issue.
In Editor, with DK2 attached, everything works super-fine.

I've searched this problem using google, but with no luck. Have you any suggestions? (Maybe it is a bug)
    This topic has been closed for replies.

    22 replies

    Inspiring
    August 22, 2016
    Thanks, we're taking a look and will follow up when we have more information.
    Inspiring
    August 23, 2016
    I saw the issue with the APK you sent, but not with one I built myself in 5.4.0p2. Can you tell me more about the GameObject hierarchy in your scene? Can you confirm all the parents above your Camera always have 0 rotation? It looks like a script might be doing something like setting rig.trackingSpace.rotation = Quaternion.Inverse(rig.centerEyeAnchor.rotation) in a Start method somewhere.
    Up and Coming
    August 23, 2016
    There are 2 cameras in the scene:
    - OVRCameraRig (only set active, when the app is in mode "main menu")
    - OVRPlayerController (only set active, when the app is in mode "in-game")

    I was setting the OVRCameraRig active the first time in the start method of my "gameplay" object and then switched between the 2 cameras (set one active and the other inactive) when the game mode changed.

    Setting the camera active in the start method seems to cause the problem (since Unity 5.4). When I set it active earlier (in Awake or right in the Unity Editor), the problem is solved!
    current GearVR project: 3D Gallery 3
    Inspiring
    August 23, 2016
    Thanks, I was able to reproduce it by writing a script that enabled an OVRCameraRig in Start. Looks like Unity is latching the wrong reference frame for the new camera when it activates. We'll get this fixed soon. In the meantime, you could either move the activation to Awake as you've done or modify the reference frame by changing the rotation of OVRCamderaRig.trackingSpace. But the second approach would be tricky to get right without a valid up vector.
    Inspiring
    August 24, 2016
    This seems to be a callback ordering issue on Unity's side. They're investigating it and we'll let you know as soon as there is progress.
    Inspiring
    September 2, 2016
    We're currently having a weird issue with OVRCameraRig...it took a long time to figure out what was happening, but I think I've narrowed it down to a specific reproduction case.

    It seems like, if the OVRCameraRig GameObject is de-active on startup, and then activated later, then it exhibits a bug, where the Camera position does not reset to 0,0,0 when the application is stopped. Instead, when stopping the game, the CameraAnchor maintains the positions/rotation it was in the last frame of the application. Next time the application is run, the previous position/rotation are used as the origin point. 

    To reproduce: 
    1. Disable the OVRCameraRig GameObject.
    2. In another monobehavior: void Start() { ovrRig.gameObject.SetActive(true); }
    3. Enter Play Mode, and look through headset. Observe as tracking seems fine.
    4. Stop Play Mode
    5. Select CenterEyeCamera in the Scene Heirarchy and observe that is has not been reset to 0,0,0
    6. Enter Play Mode again
    7. Put on the headset. Observe how the origin point is now totally broken, it is using the previous rotation and center point as it's origin.
    I'm not sure how this is a Unity issue, PSVR and SteamVR do not exhibit any symptoms like this.
    Inspiring
    September 2, 2016
    > In another monobehavior: void Start() { ovrRig.gameObject.SetActive(true); }

    This looks like the same issue @charnold reported. Can you call this in Awake instead of Start?
    Inspiring
    September 3, 2016
    Ya that did the trick. Man, that was an annoying bug to find.... Must've wasted 4 hrs completely stumped as to why it the rig was working fine in one scene and totally busted in another. Tore my whole scene apart trying to isolate the cause. Ended up being that I disabled the rig's parent in Awake() and enabled it in Start() once the save file has loaded in.
    Inspiring
    September 3, 2016
    Yes it is a bug we intend to fix soon.
    Participant
    October 10, 2016
    Is there a solution to this problem yet?