Finite State Machines in Mecanim
From this point onwards, we'll concentrate mainly on coding AI for the enemy character both in C# and in terms of visual coding for a Mecanim graph. Mecanim refers to the Unity's Animation System (http://docs.unity3d.com/Manual/MecanimAnimationSystem.html). In the upcoming sections, we'll piece together a complete class that looks at and discusses specific sections of code, and the full class source code will be pieced together as we go along. It can be viewed in the completed project in the AI_Enemy.cs
file.
To start, let's examine FSMs conceptually. When thinking about the enemy character, we can observe in them a specific set of behaviors. The enemy begins the scene by standing idle and then proceeds to wander around on patrol. During their patrol, they might see the player character. If they do so, they'll chase the player until the player comes into attack range. When the player enters attack range, they'll attack the player. Now, the only exception to...