[VR] Orientation of camera when 360 degree videos start

Hello all,

I have an issue with my oculus Go application which I am assuming is also an issue with most VR headsets and apps that play 360 degree videos.

As it stands right now whatever direction I was facing when I put the headset on that is the direction that the application will pick as “forward”. This is all well and good but there are several instances with our application where the person may have put the headset on while standing up and facing a direction and then sat down with the headset on and now is facing let’s say 90 degree to the right.

The video would now play with a 90 degree error. If I take the headset off while sitting down and put it back on and start the application again it is now oriented correctly.

My question is: How do I reproduce this re-orientation of the headset from within Unity, on-command.

I am not using the oculus SDK.

Now I don’t know about Oculus GO, but in a Rift program I used this to recenter:

using UnityEngine.XR;

But that’s on Unity 2019.2.10f1, haven’t done it with newer XR.
For steam (OpenVR) the above code did nothing, so I did reset it myself by rotating the cameraRig (the gameObject transform containing the camera) in the opposite direction of the camera (actual Unity camera). That of course demands that you have a container object containing the camera.

// Get current head heading in scene (y-only, to avoid tilting the floor)
float offsetAngle = steamCamera.rotation.eulerAngles.y;
// Now rotate CameraRig in opposite direction to compensate
cameraRig.Rotate(0f, -offsetAngle, 0f);

Hope this will help you out.