Getting a Handle on Things
Configure the Filing Cabinet to be opened by the Player
To allow the player to open the filing cabinet drawer, we need to use JOINTS…
- Use a configurable joint to restrict the drawer to only move a certain amount along a specific axis
- Using a Fixed Joint create a system that allows the player to grab the filing cabinet drawer, and open/close it
STEP 1 — RESTRICT DRAWER MOVEMENT
OBJECTIVE: Use a component to restrict the drawer to only move a certain amount along a specific axis
Using the Configurable Joint Component we can limit the cabinet drawer to only move along the z-axis, and by configuring the Connected Anchor to the closed position — and setting a Linear Limit — we can limit the distance it can move along the z-axis from the closed position.
STEP 2 —CREATE A INTERACATABLE HANDLE
OBJECTIVE: Create a system that allows the player to grab the filing cabinet drawer, and open/close it
To create an interactable handle that allows the player to naturally open and close the filing cabinet drawer, we need to create a new GameObject that holds the XR Grab Interactable Component and contains a Fixed Joint that connects the handles Rigidbody to the filing cabinets Rigidbody.
WHY NOT HAVE THE TOP DRAWER HOLD THE XR GRAB INTERACTABLE COMPONENT?
The reason we need a Handle GameObject to hold the XR Grab Interactable because, if we place the XR Grab Interactable within the Top Drawer GameObject then it (XR Grab Interactable) overrides the restrictions configured within the Configurable Joint Component