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:
- Setup the door/doorway hierachy
- Create Empty Object inside each door
- Drag the empty object from under each door, then place the door object inside this empty object
- Add collider to the door (I use Box Collider)
- Add these SteamVR scripts to the door: Interactable, Linear Drive and Linear Mapping
- Add Rigidbody to the door. Make sure Use Gravity is off, and Is Kinematic is checked.
- 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.
- Make a copy of Start, name it End. Then adjust this object to where we want the sliding to end.
- Hide both start and end game object.
- 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.
- (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.
