Game Development Reference
as shown in Figure 6.10 , as this object is never picked up. It is the
default held object. If you wanted other inventory items to be
present at the start of the game you could of course add them
in the Hierarchy as well.
FIG 6.10 Assigning the wrench as a
default inventory item.
Step 32. Key 1 for the red key, key 4 for the green key, and key 5 for
the wrench will now swap the currently held game object, but only
if you have the items in your inventory.
Step 33. Previous changes to the script will have disabled the red key
opening the red door. Before we fix this, let's add a couple of green
doors for the matching green key. Rename the existing door in the
Hierarchy to RedDoor. Duplicate the RedDoor and name the resulting
door GreenDoor. Use the green material from the green key to make
the GreenDoor green. Duplicate the GreenDoor so that there are two.
Keep their names the same. Locate the doors in the maze as shown
in Figure 6.11 .
Step 34. Modify pickup.js to test the door being collided with and the
current visible key as shown in Listing 6.14 .