Simulating and playing

Now if we hit Play, we should see the AI chase you until you've broken sight!

So, the bot will route as it did previously until an enemy is within sight. If the bot is in state 0, it will enter state 1 once an enemy is detected by the AI Perception component. Next, if one of these enemies is within sight and we have no current enemy, we will change our state to 2 and set our enemy. Lastly, we will continue to move toward our enemy until we lose sight of them, resulting in us being set back to state 0. The following diagram illustrates these transitions:

Simulating and playing

This is how we create AI without the assistance of Behavior Tree. Ultimately, ...

Get Unreal Engine 4 AI Programming Essentials 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.