Make AI Follow Other AI Objects

Hi all,

I have set up an enemy spawner that spawns enemy cubes into the level. These are scripted to move about the map until they see the player, at which point they move to the player and surround them. This works well to an extent, though there are some instances when the cubes will be facing the wrong way and they don’t ‘see’ the player at all, even if they have been following them seconds before.

As it stands, I’m currently using a blueprint with PawnSensing attached to it. The PawnSensing component is only using “OnSeenPawn” event to ‘see’ the player and then move toward them.
My questions are:

  1. How can I make the enemy cubes sense when other enemy cubes are following the player? I’d like to ideally simulate a hoarde-style mechanic where if an enemy cube in the radius of another is following the player, that other will then join the hunt.
  2. Could there be any conflicts where the enemy cubes would only follow one another? If so, how can I avoid this so they only group when they see the player? (I’m guessing some kind of branch to determine if they do see the player and an enemy cube at the same time.

This is my blueprint so far:

Any help with this would be greatly appreciated :slight_smile:

  1. When a cube senses a player use get all actors of class node and call the same behavior to everyone.
  2. I guess if you launch the same function chasing the player there are no error coming)

Thanks very much! It’s working perfectly :slight_smile:
Do you know how I could pause their behaviour as well when the player goes outside of the navmesh? I had tried setting a delay to the top “AI Move To” On Fail node, yet this just made the AI stop completely for some reason.

I also tried setting a boolean on the fail node called “Pause State”, delayed it by 5 seconds and then set the same boolean to false. I then set-up a branch to check for the pause state on every tick, but again that just paused the AI.