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:
Create a new empty GameObject named
RaceStartup
.Create a new script named
RaceStarterScript
, and add an instance of it to theraceStartup
class.This class should have a number of public variables to permit the tweaking of the race start.
In the following line of code,
stageTime
is the amount of time each stage lasts:public float stageTime = 2.0f;
In the following line of code,
numStates
is the number of states (of durationstageTime
) that need to pass before the NPCs are activated:public int numStages = 4;
In the following line of code,
currentState
tracks which actual state is currently elapsing:public int currentState = 0;
Add a float
t
to track elapsed time as shown...