Bringing behaviors into the picture

State machine behaviors are a unique, new concept in Unity 5. While states existed, conceptually, in the original implementation of Mecanim, transitions were handled behind the scenes and you did not have much control over what happened upon entering, transitioning, or exiting a state. Unity 5 addressed this issue by introducing behaviors; they provide the built-in functionality to handle typical FSM logic.

Behaviors are sly and tricky. Though their name might lead you to believe they are related to MonoBehaviour, do not fall for it; if anything, these two are distant cousins at best. In fact, behaviors derive from ScriptableObject, not MonoBehaviour, so they exist only as assets, which cannot be placed ...

Get Unity 2017 Game AI Programming - Third Edition 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.