Game Development Reference
In-Depth Information
Creating a pushable door
Doors are useful in games. Visually, it is more appealing to not have holes in the walls but
doors for the players to pass through. Doors can be used to obscure the view and hide
what's behind them for a surprise later. In extension, they can also be used to dynamically
hide geometries and increase the performance. There is also a gameplay aspect where doors
are used to open new areas to the player and give a sense of progression.
In this recipe, we will create a door that can be opened by pushing it, using a
HingeJoint
class.
This door consists of the following three elements:
•
Door object
: This is a visible object
•
Attachment
: This is the fixed end of the joint around which the hinge swings
•
Hinge
: This defines how the door should move