Search code examples
c#unity-game-enginegoogle-cardboardvirtual-reality

How to recenter vertically in GVR / Cardboard unity


Calling

GvrViewer.Instance.Recenter ();`

only recenters the view horizontally, i need it also vertically.

I'm using the latest unity beta and GVR 0.8`


Solution

  • You can recenter by making your VR camera object a child of another object (let's call it parent) and rotating the parent in the opposite direction of the rotation of your VR camera. This simple script will do (attach to parent):

    public class Recenterer:MonoBehaviour 
    {
    
        public Transform VRcam;  // drag the child VR cam here in the inspector
    
        public void Recenter()
        {
          transform.localRotation = Quaternion.Inverse(VRcam.rotation);
        }
    
    }