Making the AI chase the player

Now that we have a patrol behavior established, we should make the enemy pose some threat to the player. To do so, we will give the enemy the ability to see the player and pursue them.

Giving the enemy sight with Pawn Sensing

To grant the enemy the ability to detect the player, we need to add a PawnSensing component to the EnemyController. To do this, open the EnemyController Blueprint and click on the Add Component button in the Components panel. Search for and add the PawnSensing component. This component gives us the ability to add a few additional event triggers to the EnemyController event graph. The one we are interested in now is called OnSeePawn (PawnSensing), as shown here:

Note

There is a second system that ...

Get Blueprints Visual Scripting for Unreal Engine 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.