Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

How to recenter camera orientation on Oculus Quest in Unity?

bebop_devbebop_dev Posts: 11
NerveGear

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

Comments

  • SeabassMcGillsSeabassMcGills Posts: 3
    NerveGear
    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.
  • SeabassMcGillsSeabassMcGills Posts: 3
    NerveGear
    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!
Sign In or Register to comment.