Unity VR: Handle Pull
Intro
In this setup we have a drawer that has a Configurable Joint. There are different types of joint components, but they all allow you to control how one Rigidbody moves in relation to another. The Configurable Joint gives you full control over each of the six degrees of freedom (three for position and three for rotation), and this one only allows limited linear movement along the Z-axis to create a slider drawer.
What Not to Do
Your first thought might be to add a Box Collider to the drawer and resize it to fit the handle and slap an XR Grab Interactable component to the drawer and assign that collider.
As you can see this doesn’t produce the desired result of pulling the slide drawer, but completely ripping the drawer from the cabinet. This is happening because the XR Grab Interactable is overriding the physics engine and the Configurable Joint that is supposed to limit the drawers movement on the z-axis because the drawer is now parented to the hand and is taking on its Transform.
Fixed Joint
What we can do is add a child Cube to the drawer and resize it to fit the handle, and turn off the Mesh Renderer so we are just left with the Box Collider.
We will add a Fixed Joint component to the handle object which will automatically create a Rigidbody component since that is needed for the Fix Joint to work. A Fixed Joint locks two Rigidbody objects together, making them behave as if they were a single solid object as if they were “glued” together.
Conclusion
By using a Fixed Joint on the handle instead of placing the XR Grab Interactable directly on the drawer, we preserve the drawer’s physics constraints and allow it to move naturally along its limited axis.