Applying your new coding skills to a State Machine
You learned the fundamentals of C# coding in the previous six chapters which were used for creating Components. You will use the same coding fundamentals to create a State Machine. You have learned in Chapter 6, Using Dot Syntax for Object Communication, that an object created from a class is called an instance of the class. In Unity, an object created from a class is called a Component. These terms may be different but they mean exactly the same; an object is created as defined by a class.
However, there is a difference in the way the traditional C# environment of the State Machine gets an instance object created, and the way Unity gets a component object created. The difference is as follows:
- A class we write for Unity has to be attached to a GameObject.
- A class we write for the State Machine is not attached to a GameObject.
- Unity hides the code that is necessary to create an object. Unity knows to create the object because it's attached...