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 XR Rig - Action based controller and camera rotation

Discussion in 'XR Interaction Toolkit and Input' started by ptyalisme, Feb 23, 2021.

  1. ptyalisme

    ptyalisme

    Joined:
    Jun 25, 2014
    Posts:
    1
    I've been exploring the XR Interaction Toolkit with the action base input.

    I'm trying to figuring out why the hand tracking seem to have an offset when I rotate on myself with a camera that used rotation only.

    My objective is to be able to keep the camera in the center of the rig and having the hands following at the same distance of the camera if I rotate in my room. The reason for this is I want to add a rigidbody and a collider to the XR rig to be able to move it with physic, but I don't want to move the camera position into the rig, only the rotation for some gameplay purpuse.

    Here a test I made, I was on my chair with both arm in front of me and spin on it (the chair).
    The cube is the camera and the spheres the hands.


    Here my rig setup:
    • Oculus Quest 2 (With Oculus link)
    • Unity 2020.2.5f
    • XR Toolkit Version 1.0.0-pre.2.


    It's probably me that don't understand the tracking system, but if somebody can explain me this, It will be appreciate. I tried with the "Rotation and Position" for the Tracked Pose Driver of the camera, both hands works like a charm, but the camera is not always in the center of the rig, like expected... Sorry if this is not clear.

    Thanks for the help!
     
  2. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    226
    I would caution against doing Rotation Only for the Main Camera unless it's for a really good reason since not updating the position can cause motion sickness in users. Even when someone thinks they are holding their head still, the head still moves enough where those subtle movements not causing a corresponding perspective change in the application can feel bad.

    As to why you are seeing the behavior in the video, the HMD position is to the left of the center of the XR Rig, near the pivot of where the controllers are rotating about (since you are spinning in your chair). If you want the controllers to continue rotating about the locked Camera position, you would need to add a parent GameObject of the controllers and offset it by the negated local position of the tracked HMD position.

    However, a better approach could be to move the Character Controller/Rigidbody and Collider based on the location of the Camera instead of trying to force the Camera to stay centered in the rig. You can look at the WorldInteractionDemo scene in the VR project of the XR Interaction Toolkit Examples which uses a Character Controller Driver component to do that. You could monitor the location of the HMD and if it deviates too far away from the collider, you could teleport the rig to undo the move.