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 ...

Get Mastering Unity Scripting now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.