Forum Discussion
chadstitch
7 years agoExplorer
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, ...
leozheng.2023
2 years agoExplorer
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.
confy247
2 years agoExplorer
Very helpful and useful! Thanks for saving me a lot of time!
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device