Game Development Reference
In-Depth Information
Whenever the player collides with an object, this script send Unlock message to that object
and provides it with the list of keys stored in player's inventory box. If the colliding object is
a locked door, it will try all provided keys to unlock itself. However, if the colliding object
is not a door, the message is simply ignored and nothing evil happens. In scene20 in the ac-
companying project, you can find two functional rotating doors: unlocked and locked with
a collectable key.
The second type of doors we are going to implement is sliding door. This time we use a
custom script instead of a physics component to implement the desired door movement.
The generic functionality this script has to provide is moving the door along its local x axis.
However, to make a real door, we need to do more than that. First of all, we need to provide
the functionality of a generic door, such as opening, closing, locking and unlocking. In the
case of rotating door, hinge joint properties did the job for us. We need, however, to do
handle these situations by ourselves now. Therefore, we need GeneralDoor script that re-
presents an abstract door, regardless of the actual way of opening and closing it. This script
is shown in Listing 66.
Search WWH ::




Custom Search