Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to detect recenter on Quest/Meta devices

Discussion in 'VR' started by Wattosan, Mar 9, 2023.

  1. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    456
    Hello,

    How can I detect when the player has recentered themselves by long-holding the Oculus Home/System button?

    It seems quite clear that it is not possible to query that button. But I'm also unable to find if there is perhaps a recenter event I could subscribe to? In this case I could use my own custom recentering logic to correctly position the player in the game.

    I've noticed that various games have sold it somehow (Beat Saber, Prisms) so I'd like to think it is possible in a sensible way.

    Best
     
  2. Tanya_Li

    Tanya_Li

    Unity Technologies

    Joined:
    Jun 29, 2020
    Posts:
    104
    In OpenXR XR Plugin package, https://docs.unity3d.com/Packages/c...OpenXRFeature_OnAppSpaceChange_System_UInt64_

    According to the OpenXR spec: https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrEventDataReferenceSpaceChangePending.html
    The XrEventDataReferenceSpaceChangePending event is sent to the application to notify it that the origin (and perhaps the bounds) of a reference space is changing. This may occur due to the user recentering the space explicitly, or the runtime otherwise switching to a different space definition.
     
  3. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    456
    Thank you!

    However, we are not using OpenXR as the backend but rather the legacy LibOVR + VRAPI.
    How do we achieve this with the legacy backend?
     
  4. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    456
    We found we can use the OVRManager:
    Code (CSharp):
    1. OVRManager.display.RecenteredPose += () =>
    2. {
    3.     // Reset player position here
    4.     // ...
    5. };
    6.  
     
    georges-m likes this.
  5. RichardRevesz

    RichardRevesz

    Joined:
    Jul 4, 2018
    Posts:
    12
    If you are reading this and wondering how to do that in OpenXR, see my response here:
    https://forum.unity.com/threads/how...anagement-in-unity-2020.1117141/#post-9139225

    You will need to enable the feature in Porject Settings, XR Plug-in Management, OpenXR, go find Reset View Feature under the OpenXR Feature Groups

    You can add a listener to the event like this:
    Code (CSharp):
    1. ResetViewFeature.AppSpaceChanged.AddListener(YourFunction);
     
  6. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    456
    For some reason OVRManager.display returns null. For new builds (after updating Unity and Meta SDKs), but also for builds already released in store.

    I'm wondering if Meta changed something so this no longer works.