Skip to main content
October 15, 2019

How to recenter camera orientation on Oculus Quest in Unity?

I want to reorient the camera to the start position and rotation in my Unity app.

I tried this function, but it's not working on Oculus Quest: 

OVRManager.display.RecenterPose();

I noticed that the Oculus Quest home button on my Quest after a firmware update spawns the quit/resume app sub-menu, but does not reorient the position and rotation in the app. On an another Oculus without the firmware update, the home button still works.

I want to know if there's a way to directly call the native code for homing. I can tell through ADB that Oculus knows when the home button is pressed: 

I/InputHooks_Internal: InputHooks::nativeSetHomeButtonDown(5868.719727): 1698898178

This topic has been closed for replies.

8 replies

New Participant
October 16, 2019
I would also love an answer to this question. Have spent the last two nights desperately trying to find a way to reset the view when a new scene loads in Unity. In addition to the RecenterPose() method I also tried using the "Reset Tracker on Load" checkbox on the OVR Manager component (which, of course, doesn't work). Really wish the documentation / support was better here.
New Participant
October 16, 2019
Found a workaround that will work for now in my case. More specifically, my issue was as follows:

My game has a sequence of scenes that get loaded as the player progresses through. On a couple scenes in particular, the player can sometimes end up facing in a direction that I didn't intend, depending on what they're looking at when the transition happens. When the next scene loads in, the facing direction did not reset, and so the player could be staring at a wall wondering what the heck they're supposed to be doing. For this reason, I was trying to recenter the pose / camera on the scene load, before the frame faded back in.

As stated earlier, I had no luck (and still have had no luck) getting the 
OVRManager.display.RecenterPose();
command working on the Quest. It seems to work fine on my Oculus Go, but not the Quest.

Anyways, the workaround I stumbled upon was this:
public Transform OVRPlayerController;
    private bool displayExistedLastFrame;

public override void RecenterDisplay()
    {
        Service.UpdateManager.AddObserver(OnUpdate);
    }

    private void ActuallyRecenterDisplay()
    {
        OVRPlayerController.localEulerAngles = Vector3.zero;
    }

    private void OnUpdate(float dt)
    {
        if (displayExistedLastFrame)
        {
            ActuallyRecenterDisplay();
            Service.UpdateManager.RemoveObserver(OnUpdate);
        }

        displayExistedLastFrame = OVRManager.display != null;
    }
To clarify a bit, I have a central update manager service that a register and revoke listeners to depending on the needs of any given class. In this case, I use it to wait 1 frame after the
OVRManager.display
becomes available. No idea why this is necessary, but if it works, then I'm done wasting time spinning my wheels on this problem for now.

I'm sure there are better solutions out there for this, and maybe if we're lucky someone from Oculus can get a better answer, but for now, I hope this answer helps you a bit on your end :)

Cheers!
Participant
February 18, 2020
Sorry, could you explain better your code? 
I've the same issue but didn't found all the code you posted.
thanks
Inspiring
January 21, 2021
This is still an issue oculus SDK is a joke. 
Participant
February 3, 2021
New Participant
July 14, 2021

This code from emalafeew works for me!

   public void Recenter()
   {
      mBoundary = OVRManager.boundary.GetGeometry(OVRBoundary.BoundaryType.OuterBoundary);

      Transform cam = Camera.main.transform;
      float yawOffset = -cam.localEulerAngles.y;
      float ang = -yawOffset * Mathf.Deg2Rad;
      float sinAng = Mathf.Sin(ang);
      float cosAng = Mathf.Cos(ang);
      float xOffset = cam.localPosition.z * sinAng - cam.localPosition.x * cosAng;
      float zOffset = -cam.localPosition.z * cosAng - cam.localPosition.x * sinAng;

      CameraOffset.localPosition = new Vector3(xOffset, 0, zOffset);
      CameraOffset.localEulerAngles = new Vector3(0, yawOffset, 0);
   }
New Participant
July 15, 2021

is there more to this code?  mBoundary is never used, and unsure what CameraOffset is referencing. also cannot find original post from virzoom.