Summary

This chapter was full of options and details about using the State Machine. We started by creating four States and setting up the StateManager class to be the controller with the help of a C# interface. We learned how to load Scenes when switching States, and keep GameObjects from being destroyed in the process. We also covered using timers and how to pause a Scene.

For such simple code, the State Machine offers a tremendous amount of control and flexibility in organizing your game code. Let's start off the next chapter by using this State Machine to actually control a few GameObjects and change States.

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.