Game Development Reference
In-Depth Information
Creating the raceStartup Prefab
Recall that the second Prefab that is enabled when the popup_Level2Start windows
is clicked, is the raceStartup Prefab. This object will commence the start of the
other racers, leaving room for an eventual countdown clock. Let's start creating the
raceStartup Prefab by performing the following steps:
1. Create a new empty GameObject named RaceStartup .
2. Create a new script named RaceStarterScript , and add an instance of it
to the raceStartup class.
3. This class should have a number of public variables to permit the tweaking of
the race start.
4. In the following line of code, stageTime is the amount of time each stage
lasts:
public float stageTime = 2.0f;
5. In the following line of code, numStates is the number of states (of duration
stageTime ) that need to pass before the NPCs are activated:
public int numStages = 4;
6. In the following line of code, currentState tracks which actual state is cur-
rently elapsing:
public int currentState = 0;
7. Add a float t to track elapsed time as shown in the following line of code:
public float t;
8. Add two GameObject references to NPCs to activate as shown in the following
lines of code:
public GameObject npcA;
public GameObject npcB;
Search WWH ::




Custom Search