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 VR Hands in a moving obejct.

Discussion in 'VR' started by XSpitFire, Apr 6, 2023.

  1. XSpitFire

    XSpitFire

    Joined:
    Jan 22, 2018
    Posts:
    15
    I have a car setup and the player can turn the steering wheel with their hands. Its pretty basic :

    1) A car is setup with the XR Origin as a child. So when the car moves it (the player) moves with.

    2) Both hands have a Tracked Pose Driver on (set to Update and before Render). That sets the Position and Rotation of the hands. Both hands also have a Sphere collider set as a trigger.

    3) The steering wheel has a collider and a Rigidbody.

    4) When the hand's sphere collider enters the steering wheel, it calls the on trigger enter where I start tracking the player's hand movement to rotate the wheel.

    This all works well when the car is standing still. But when the car starts moving a bit faster it seems the hand is exiting and entering every second frame or so even though the player is not moving. I can only image that the car's physics is updated in the FixedUpdate and that then moves the steering wheel out of the sphere collider. Then some time later the hand is updated and returned to that position.

    I have no idea where to start poking at this.
    Is it okay to have the XR Origin as a child of the car that has a rigidbody ?
    Any comments are welcome.
     
  2. XSpitFire

    XSpitFire

    Joined:
    Jan 22, 2018
    Posts:
    15
    I made progress by not having the player be in the car. The player and controls are static and not rendered by the camera. By being static there are no problems with physics anymore. I just then copy the head and hand movements to the car.