Skip to main content
Participant
June 13, 2019

Unity UnityEngine.XR.Recenter not working on Quest

Hi all, I'm having a weird problem where I'm trying to call the 
Recenter

function. So I am currently trying to develop on the rift, and then building on the Quest. However, I am facing a problem, when I call the recenter function on the rift, everything works perfectly and as intended. However, when I test it on the Quest, the function does not seem to work at all. Does anyone have the same thing? 


If it matters, I'm using Unity 2018.4.0f1 LTS


Thanks all!

This topic has been closed for replies.

17 replies

Participant
February 6, 2021
If you want to know when the user recenters their display, you can subscribe to:

OVRManager.display.RecenteredPose

It is reliably called each time the user triggers a recenter using Oculus Quest, after the camera has been repositioned. I don't believe it is invoked for Rift Reset View.
New Participant
June 21, 2021

if you dont mind the users still using the oculus home to reset orientation. you can also include your own code to be called when it is pressed by using this.
void Start()
{
           OVRManager.display.RecenteredPose += PlayerPressedOculusHome;
}
public void PlayerPressedOculusHome()
{
            Debug.Log("I Have Detected a headset Reset");
}

New Participant
April 2, 2022

Hey SergantTeddy!  That tip was awesome, and worked perfectly for what I needed, thanks so much!  I have a strange thing with it though, maybe you have some insight?

It works perfectly, the first time I do it... but subsequent resets of the orientation starts an explosion of errors though:

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
CocklpitBoundingMagic.PlayerPressedOculusHome () (at Assets/Scripts/CockpitModeStuff/CocklpitBoundingMagic.cs:47)
OVRDisplay.Update () (at Assets/Oculus/VR/Scripts/OVRDisplay.cs:125)
OVRManager.Update () (at Assets/Oculus/VR/Scripts/OVRManager.cs:1818)



SO... I assumed maybe this was a case of "I'm piggybanking off this OVRManager, but when I reset the view, that gets deleted or something, so my connection to the old one is now invalid".

I think there's some validity to that theory because I tried redoing the:
"OVRManager.display.RecenteredPose += PlayerPressedOculusHome;"
line every time I reset the view, and that fixes that error, presumably because it's resetting the connection to the newer element, but it only works as long as I have that script open and running forever in the project, haha.  Not great.

So yeah, any alternate or more stable ways to try and detect an orientation reset?  Thanks in advance if so 🙂

New Participant
June 27, 2024

I have the same problem when developing a game player can sit to play, so the head pose recenter is every useful when loading a new scene.

After digging more about those APIs, I found none of them works on my quest 2, so decide to recenter it by myself. The code is sample:

1. Record the FIRST head position and rotation.

2. Add a parent root for both head and hand gameobject, call it TrackingSpace.

3. Set the position (Quaternion.Inverse(FirstHeadRotation) * -FirstHeadPosition) and rotation Quaternion.Inverse(FirstHeadRotation) to TrackingSpace.

4. Then set head and hand position normally(directly from OVRInput or InputSystem).

 

In order to make height of head take effect, I set the Y axis of FirstHeadPosition to zero in step 3, so player could still put their head lower or higher.

 

Also, if player long press menu button from controller to reset the view, I also can't get called from RecenteredPose callback from SDK, but fortunately, I found OVRPlugin.GetLocalTrackingSpaceRecenterCount() will plus 1 every time I reset the view form controller, so I can check this to decide to record the latest position and rotation as FIRST head position and rotation, and then set them to TrackingSpace to finish the reset view inside game.

 

Hope those helps.

Participant
December 7, 2024

Very helpful and useful! Thanks for saving me a lot of time!