Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question XR Recenter Not working in Oculus Quest 2

Discussion in 'VR' started by muttsang, Jun 21, 2021.

  1. muttsang

    muttsang

    Joined:
    May 15, 2018
    Posts:
    10
    Hi,
    I'm trying to make it so that when the user presses the "A" button on the oculus quest 2 controller.
    It triggers this function and resets the camera.

    In the attached image, the commented out code is the new and recommended way of doing it and the Uncommented one is the old/obsolete one.

    Both methods work like a perfectly when I'm testing in the Unity editor with the Oculus Headset hooked up via Oculus Live link. When I build and run it on the headset, it doesn't work.

    I'm not sure why this is happening. Can anyone help me please?


    thanks
     
  2. dpcactus

    dpcactus

    Joined:
    Jan 13, 2020
    Posts:
    39
    I recently had the same question, turns out, that Quest doesn't support Recenter in native mode.
     
    muttsang likes this.
  3. muttsang

    muttsang

    Joined:
    May 15, 2018
    Posts:
    10
    Hi,
    Did you find an alternative solution for this ?

    I am currently thinking of moving the world to the player instead of trying to recenter the user. I'm not sure if it'll work at all.
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You should have a parent object that the camera (head tracking) is inside. This parent object is displaced as tracking works in local space.
     
  5. muttsang

    muttsang

    Joined:
    May 15, 2018
    Posts:
    10
    I'm not quite sure if I understood what you meant by this?
    I am using XR interaction toolkit with the XR Plugin and Unity gives their own XRRig which has this structure; the MainCamera->CameraOffset->XRRig. Main Camera is a child of Camera Offset and it is a child of XRRig.
    When I move, only the MainCamera's position is changing and the rest doesn't change.
    But again, I'm not sure what to do with that information?
     
  6. imjusthere

    imjusthere

    Joined:
    Oct 12, 2012
    Posts:
    66
    Teleportation seems flawed if you can't recenter the player on teleport. In my case I have a VR grocery store and the user is trying to teleport near a shelf to grab an item. Depending on where they are in the play space they might end up in the shelf or several steps away from it.

    Does anyone have a solution for this?
     
  7. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    XR tracking is relative to a parent object.

    Therefore you can work out how much to shift the parent in order to recenter the player on teleport. The camera's local position is usually used to offset the parent so you can recenter on teleport.

    Move the parent of the camera.
     
  8. imjusthere

    imjusthere

    Joined:
    Oct 12, 2012
    Posts:
    66
    This works for positioning the character controller (I'm using the Oculus SDK) but it's causing another problem. It's then possible for the character controller to land off of the navmesh which is used for teleportation and strands the user. For those of you needing to fix the positioning it looks something like this:

    Code (CSharp):
    1. Vector3 destPosition = destTransform.position;
    2.         destPosition.y += character.height * 0.5f;
    3.         destPosition.x = destPosition.x - _mainCamera.transform.localPosition.x;
    4.         destPosition.z = destPosition.z - _mainCamera.transform.localPosition.z;
    5.         characterTransform.position = destPosition;
    EDIT - I was able to get the teleportation working by finding the nearest point on the navmesh using MavMesh.SamplePosition to the destination point and storing it. Then I always have a valid starting point to use for the NavMesh check.
     
    Last edited: Jul 9, 2021
  9. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,766
    Note from the team:

    The call to recenter will only work when the in a device tracking origin mode. This is a platform limitation.