I have previously written about my approach on scripting how to pick things up in VR in Unreal Engine 4 for my four week long school project. This time I will write about how I took that approach and applied it to scripting a door with a door handle.

The goal is to create a believable door in VR, with features of a real door. The player must pull down the handle and push or pull to be able to open the door.

To reiterate the previous post, I used physics handles to script so that the player can pick up objects and move them around without losing collision on the object and not getting any bad clipping problems etc. The physics handle “pinches” the object at the location the player hold his hands and then moves following the player’s hand. The handle then drags the object along with it, allowing it to simulate collision and physics along the way.

I’m using the same technique here. When the player interacts with the door a physics handle will pull down the handle and the door.

Rotation

To simulate the rotation of the door in the hinges and the handle in the latch bolt, I used the Physics constraint component in Unreal.  This component is used, as it says, to constrain physics actors in different ways. The component has support for limiting an object to move both in linear and angular motion. For the door I used only the angular limitation.  I tested this out and got some nice results.

To get the door handle to keep upright I used a feature in the physics constrain component called motion. That feature applies a force on the constraint object in a specified direction. I applied angular motion on the handle upward against the ground and it was done.

What I did next was to apply the physics handle to the blueprint the same way as before. When the player put his hands  to the door handle the physics handle “pinches” the door handle and moves the handle alongside the player’s hands with the same approach as the previous post.

Fine tuning

I now had the basics of the door down but it still needed some fine tuning to feel right in the game. The first thing is adding script so that the door can’t be opened unless the handle is pulled down, the second thing is creating some feedback to the player that this door can be opened. I solved both these problems with the same solution.

I added a little collision box at the top of the door, slightly to the side. This collision box only collides with the door and prevents it to be fully opened. When the handle is pulled down the box is deactivated and the door can be opened. By placing it slightly to the side of the door I created a little wiggle room for the door to wiggle in while it is closed. This signals to the player that the door is intractable and movable when they grab the handle.

More fine tuning

After this I needed to fine tune the door even more. Lots of parameters like the dampening of the door and the specific angular motion of the handle needed to be calibrated to get the right feeling. Most surprising to me was that the door felt much better when disabling gravity on both the handle and the door. I theorize that  when removing the extra force on the door downwards the physics simulation of the door when pulling or pushing it became less complex and therefore more responsive.

That’s all for now!

Best Regards!

Simon Engqvist