Game Development Reference
In-Depth Information
5.2 Puzzles and unlock combinations
This section is an extension of section 5.1, in which we will continue to work on the sliding
door we have already made. This sliding door is going to be locked using an electrical
central lock, and the player has to solve a simple puzzle to unlock the door and open it.
What we need to do now is to add SlidingDoor script to the two parts of the door and con-
figure their sliding directions to, say, (1.2, 0, 0) for the right part and (-1.2, 0, 0) for the left
part. GeneralDoor script considers the door as unlocked if the value unlockKey is empty.
Since we need locked doors, we need to put some value such as “door2” for this variable
for both parts. Now we can create our central lock. This can be an empty game object that
has the necessary scripts attached to it. The first script is the part of the lock that controls
door parts. CentralLock script is shown in Listing 68.
Search WWH ::




Custom Search