Time for action – adding the code to change the Scenes

We'll add a single line of code in BeginState and in LostState to change Scenes.

  1. In BeginState, add Application.LoadLevel("Scene1"); into the Switch() method on line 42 as shown in the following screenshot:
    Time for action – adding the code to change the Scenes
  2. In LostState, add Application.LoadLevel("BeginningScene"); into the StateUpdate() method on line 20 as shown in the following screenshot:
    Time for action – adding the code to change the Scenes

    If earlier in this chapter you changed WonState to switch to PlayState instead of starting over with BeginState, we're ready to test our State Machine again. ...

Get Learning C# by Developing Games with Unity 3D Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.