Search Unity

Question Parent XRController to FPS camera issue (for editor testing)

Discussion in 'XR Interaction Toolkit and Input' started by R1PFake, Aug 27, 2021.

  1. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    542
    I tried to use a FPS controller to test my XR game without using the actual headset / controller all the time.

    My goal was to use a normal FPS controller (I used the new Unity Starter Asset) and then just drag the XR Controllers as a child of the FPS camera, so they would move with the FPS movement.

    The movement and rotation of the XR controller visual follows the camera, but the XR Ray Interactors of the XR Controllers don't align properly, they always aim at the same position and "ignore" the controller rotation.

    I assume this is a issue because the controller tries to read the tracking position / rotation of the actual VR controller, which is not available. I also tried to disable the "Enable tracking" setting on the XR Controller but that didn't change anything, the rotation of the Ray Interactors was still wrong.

    I know there is a device simulator package, but that doesn't work for my use case, because with that pack you still have to make some explicit inputs to move the device / controller. I don't want to "simulate" input, I want to rotate / move the XR controller simply by parenting them to the FPS camera.

    Is there any other way to get the XR Interactors (Controllers) to work properly with this prototype setup?
     
  2. DejaMooGames

    DejaMooGames

    Joined:
    Apr 1, 2019
    Posts:
    108
    Yes, but it is a bit more involved than you may think. I have made one that works for a project I am on currently. I would start looking into writing your own interactor that inherits from the XrBaseInteractor class not XRBaseControllerInteractor. You will have to supply all the object selection behavior by overriding the GetValidTargets, ProcessInteractor, CanSelect methods. Look at what the RayInteractor does as an example.