How it works...

We have the finite-state machine system that is the animator engine. First, we create the states and transitions that the agent will have. Second, we create our own behaviors deriving from the StateMachineBehaviour class, and attach them to the corresponding state. Also, we retrieve information needed from our game objects and script components to make decisions inside of each state. If required, we call the proper trigger to change states, thus changing the agent's behavior.

Get Unity 2018 Artificial Intelligence Cookbook - Second 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.