SteamVR Sliding Door Interaction

As I walk around the Japanese Mansion project, I noticed it would be nice if I can open and close the slide door. I guess my brain was tired yesterday, so not until today I realized drawer interaction should have the same physics as slide door. When I mentioned it to PG, he was just looking at me with the ‘oh, I thought you already know’ look @_@

So I look up ‘steamvr unity drawer’ on youtube and found this tutorial by Dash-Gaming. I’m not using Unity latest’s XR library, so I specifically looking for SteamVR tutorial in this case.

Step-by-step of my slide door based on this tutorial:

  1. Setup the door/doorway hierachy
  2. Create Empty Object inside each door
  3. Drag the empty object from under each door, then place the door object inside this empty object
  4. Add collider to the door (I use Box Collider)
  5. Add these SteamVR scripts to the door: Interactable, Linear Drive and Linear Mapping
  6. Add Rigidbody to the door. Make sure Use Gravity is off, and Is Kinematic is checked.
  7. Make a copy of the door and name it Start. Remove the Interactable, Linear Drive and Linear Mapping scripts. Also remove the Rigid body. For the collider, set x, y and z size = 0.05.
  8. Make a copy of Start, name it End. Then adjust this object to where we want the sliding to end.
  9. Hide both start and end game object.
  10. Go to the door object. Under Linear Drive component, assign Start game object as Start Position, End game object as End Position, and the Door game object as Linear Mapping.
  11. (Optional) Under Interactable component script, we can set Highlight On Hover off.

Save your scene, and test it out! This works for me.. I’ll need to tweak it a bit to see if I can simplify it further.