After sliding door, we have swinging door interaction this time. I started by watching this youtube tutorial:
I got the handle portion to work, but the door panel portion was being wonky. So I simplify my model hierarchy. I made sure holding the handle can open the door panel instead, and worry about modeling the real handle later on.
What I did:
- Place door handle as child of the door panel, and put a collider on it. I use box collider for mine.
- On the door panel object, check the rotation values. To save a headache, I created an empty game object, pull it out of the door panel, and place door panel inside this empty game object. This way, the door panel rotation values are at 0,0,0.
- On door panel object, add SteamVR Circular Drive script. This will automatically add Interactable script component as well. In Unity, try rotating the door panel to how you want it to swing, while take note on which X/Y/Z value we change. On mine, it should swing from 0 to -90 degree in Y Axis.
- Set the values in Circular Drive script. Based on my values, Limited Rotation Min Angle = -90, Limited Rotation Max Angle = 0, Axis of Rotation = Y-Axis.
- Make sure Limited Rotation – Limited is checked!
- Since I want the handle as the object that control the door, drag Door Handle to Child Collider.
- Test in VR. Don’t forget to add SteamVR Player or camera if you haven’t done so.
This worked okay for me. The door felt really heavy, like I had to put more energy in opening and closing it. So I add Rigidbody to the door panel itself, and set Angular Drag to 0 (uncheck Use Gravity, and check Is Kinematic). This seems to make it easier to open the door. Maybe I’ll play around with the mass too, we’ll see how it goes.
