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

XR reset origin of room scaling simulation

Discussion in 'AR/VR (XR) Discussion' started by bricefr, Jun 28, 2020.

  1. bricefr

    bricefr

    Joined:
    May 3, 2015
    Posts:
    61
    Hello guys,

    I need some help here. I'm implementing a simulation using the XR package. The test device is a Quest with room scaling enabled.

    I have this kind of rig:


    + Player
    + Rig
    + Head (Camera + TrackedPoseDriver)
    + LHand
    + RHand
    + ...
    + ...


    During the movement of the player, given the room scaling is on, the Head GameObject transform is moved within the Rig. The Player GameObject is usually fixed. So an "offset" appears between the Player world transform, and the Head world transform. Everything about the gameplay is working (even with dynamic gravity).

    But when I want to "teleport" the player, I have to teleport the Player GameObject completely for many reasons. But I also have to find a way to "reset" the local transform of the Head within the Rig node. Otherwise when the teleportation is finished, the player keeps it's initial offset and he doesn't appear where he is supposed to (I really want to have the Player GameObject position set to the exact teleport target point).

    I guess I have to find a way to tell the XR subsystem: "ok, the current headset position is the new origin" and reset the local transform position to zero at the same time. And this is where I'm stuck... I have tried a bunch of stuff:
    • In a coroutine: changing the TrackedPoseDriver tracking type to rotation only + wait for next frame + force the local transform position to zero + re-enable to rotation and position of the TrackedPoseDriver. I also tried to disable it completely during the end of the frame and forcing the position. But I think this is useless since the TPD only sync the data from the subsystems to the Transform they are attached to.
    • Disabling and re-enabling the head subsystem between two frames while resetting the local transform.
    • Calling TryRecenter on the devices of the subsystems, and even if it's returning true (success) if doesn't work. Also I'm not sure this is what I'm looking for.
    • ... maybe set a Pose Provider custom implementation on the TrackedPoseDriver during one frame to set the position/rotation to the values I want?
    Any help would be appreciated... I'm starting dreaming about those XR subsystems, it's not good ;-)

    Thanks
     
    Last edited: Jun 28, 2020
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Tricky. I have a similar issue with my teleport function, but I chose to ignore it. :)

    I suspect the solution might be to adjust the Rig (which I think is normally called Camera Offset in Unity's samples). This is usually used to adjust the height of the camera above the floor, e.g. to accommodate both standing and seated players. But you could also use it to get that horizontal translation you're looking for. The player will continue to move around within their room-scale play area, but whenever they teleport you would adjust this Rig offset as needed.
     
  3. bricefr

    bricefr

    Joined:
    May 3, 2015
    Posts:
    61
    Thanks for your feedback JoeStrout.

    I ended up removing everything (TrackedPoseDriver, CameraOffset, …) and implementing the XR devices/GameObjects sync myself. Way easier this way.
     
    JoeStrout likes this.