Game Development Reference
In-Depth Information
Step 22. There are also five pickup objects at the top of the script,
which will hold onto the wrench and keys that have been picked
up. When a game object exists, the associated colored key icon will
appear in the GUI.
Step 23. Open pickup.js and edit the code as shown in Listing 6.10
to cause the red key icon to turn on when the character picks up
the red key.
Step 24. The new script will set the haveRedKey Boolean value in the
gui.js script to a value of true when the RedKey is picked up. This will
cause the GUI to display the red key icon in place of the grayed out
one. Play to test it.
Listing 6.10 Setting a Boolean Value for the Inventory
var attachPoint: GameObject;
private var currentObj: GameObject;
. . .
function OnControllerColliderHit (hit : ControllerColliderHit)
if(hit.gameObject.tag == "door")
. . .
else if(hit.gameObject.tag == "key")
. . .
if( == "wrench")
. . .
hit.gameObject.transform.localPosition =
hit.gameObject.transform.localScale =
hit.transform.localEulerAngles =
if( == "RedKey")
Camera.main.GetComponent("gui").theRedKey =
. . .
Search Nedrilad ::

Custom Search