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