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