Book Image

Creating E-Learning Games with Unity

By : David Horachek
Book Image

Creating E-Learning Games with Unity

By: David Horachek

Overview of this book

Table of Contents (17 chapters)
Creating E-Learning Games with Unity
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 currently elapsing:

    public int currentState = 0;
  7. Add a float t to track elapsed time as shown...