Game Development Reference
In-Depth Information
Creating the Time object
The Time object will implement the game's clock functionality in this level. If the time
ever reaches zero, this class will display the mission failed pop up. Recall that the
source of the added pressure this time around is the clock ticking down to zero. We
want this because a little pressure makes the game fun and encourages cognitive
flow. Perform the following steps to create the Time object:
1. Create a new script named TimeScript.cs . Add an instance of it to a new
GameObject of type GUIText . Place GUIText on the left-hand side of the
screen opposite the score. Note, this is done by adjusting the PixelOffset field
of the GUIText component, and not by moving the transform (this is one of
the few exceptions to the rule when placing objects in Unity).
2. A pixel inset of -60 , -20 looks good at a screen resolution of 1024 x 768.
Some of the settings for the GUIText component are shown in the following
screenshot:
3. Add the following four variables to the script:
public GameObject failPopup : This variable will hold the ref-
erence to the pop up that is displayed if the user fails the mission by
letting time run out.
Search WWH ::




Custom Search