Search code examples
unity-game-engineoculus

Unity3D Getting position of OVRCameraRig


I want to attach an object to the OVRCameraRig and then use its position, which is offset from the rig.

However, my object is always static, irrespective of where the headset is.

This only happens with the OVRCameraRig. If I use a normal MainCamera I get the right data. But I'm not getting other aspects, like floor level, of the OVRCameraRig!

Is there some way to get the actual position of the OVRCameraRig?


Solution

  • Afaik the OVRCameraRig itself doesn't move.

    What you probably want to get is the position of the centerEyeAnchor instead

    // somehow get the reference e.g. using GetComponent
    OVRCameraRig overCameraRig;
    
    var position = overCameraRig.centerEyeAnchor.position;
    

    Regardless of the value of usePerEyeCameras the centerEyeAnchor's position is always updated.