How to do it...

Let's set everything up first:

  1. First, create a new Animator Controller using the Create button in the Project window, as shown in the following screenshot:

  1. Next, create a new default state called Wandering.
  2. Then, create a new state called Pursuing.
  3. Next, connect both states to each other, and back, with two transitions, as you'll see in the following screenshot:

  1. Now, we create two trigger parameters: Pursue and Wander, as shown in the following screenshot:
  1. Next, assign the Wander parameter to the set of conditions in ...

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition now with O’Reilly online learning.

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