Search Unity

Question Get controller rotation from XRController to set it as the other controller's rotation.

Discussion in 'XR Interaction Toolkit and Input' started by InigoPanos_UPNA, Feb 11, 2021.

  1. InigoPanos_UPNA

    InigoPanos_UPNA

    Joined:
    Oct 28, 2020
    Posts:
    1
    Hello, I'm trying to build a system where when there is only one controller being used, the other hand appears and moves and rotates mirroring the active hand. I have already figured out the position and animation mirroring, however I can't seem to get the rotation correctly. I tried doing it the simple way (this.transform.rotation = other.transform.rotation) adjusting for negative z value for the mirroring. I'm now trying to access the rotations found on XRController, deviceRotation (line 311) and and UpdateControllerPose() (line 397), but I can't seem to access them. The attached picture is what I've managed to get, but I can't access what I want from there.

    Any help is appreciated.

    upload_2021-2-11_12-14-10.png
     
  2. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    231
    You can override
    XRBaseController.UpdateTrackingInput
    in a derived class and set the position and rotation of the
    controllerState
    that is passed to the method. Then those values in that state class will be applied during
    XRBaseController.ApplyControllerState
    so you won't need to use any of the internal methods to achieve what you want.