Making our enemy tank move

You may have noticed in addition to the variables we didn't cover yet, that our tank has no logic in place for moving. This can be easily handled with a substate machine, which is a state machine within a state. This may sound confusing at first, but we can easily break down the Patrol state into substates. In our example, the Patrol state will be in one of the two substatesmoving to the current waypoint or finding the next waypoint. A waypoint is essentially a destination for our agent to move toward. In order to make these changes, we'll need to go into our state machine again.

First, create a substate by clicking on an empty area on the canvas and then selecting Create Sub-State Machine. Since we already have ...

Get Unity 2017 Game AI Programming - Third Edition now with O’Reilly online learning.

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