Download

What is the best way to make enemy AI intercept and surround instead of just chase?

Hello all,

I am learning how to prototype a game with Blueprints.  I have 3 different enemy AI blueprints implemented, lets call them Red, Yellow, and Blue.   Right now they have patrolling, wandering, pawn sensing, chasing, and attacking implemented.  They all chase the player with "Move To" in their "Behaviour Tree", but they can be herded easily just by running back and forth.  I want them to do a co-ordinated attack.

I want Red to chase the player all of the time.
I want Yellow to have a target destination based on the direction the player is moving in and a little ahead of the player.
I want Blue to have a target destination based on the direction the player is moving in and be a little behind the player.

 So my questions are:  What is the best way to figure out what direction the player has been moving in and set this as a target destination?  Should the target destinations be an actor?  Should it be a vector variable?  How often should I calculate it?  Where should I store it?    

 Any input will be greatly appreciated

Thanks

You could try storing an array of Vectors that act as like a location history for the player, which can be updated in any particular interval, you just need to add sufficient time for the player to move away before the AI starts using the location history as target destinations.

So say for example you could put in a condition that says when the Location History array has more than 4 items then the AI starts using them like waypoints. The array only gets changed when the Player is actually moving and obviously you would remove the locations from the history array after the AI has arrived at them.

AI that moves ahead of the Player is a little trickier. You could probably just do a simple location offset from the player in the forward direction or you could go the sneakier route and try calculating the perceived trajectory of the Player based on their velocity.

You could also add an aggro system, and increase aggro for instance on range or time of influence, or on reputation. In the meantime the AI could roam in random directions, or follow a waypoint path, or idle, or do tasks.

I like the idea of a location offset. Where can I find more info on how to implement that?

Basically all you do is take the Origin location, which in this case would be the Players world location and then take an offset by X amount of that vector.

So for example you could just use Players location Vector + Offset Vector = New AI Goal Vector.