Stop AI from moving past the player

Hello,

I am developing an AI for ranged combat. I set up some conditions for movement with the Environment Query System. There are situations though in which the AI chooses a point to move to, which is behind the player and thus runs past him very closely.

I tried using RVO Avoidance and Detour Crowd System with mixed results.

I am searching for a way not only to get the AI keeping a distance to the player, but also not trying to find movement targets that are behind the player (from the AIs point of view - so independantly from anyones look direction).

It shouldn’t be impossible though so the player can’t lock up the AI in a corner or similar.

Here is a sketch of what I am trying to achieve:

Hello,
Have you tried using a DOT product to score the items?
The result of the DOT product would be greater than zero for items that are in front of the player

Thank you! I think this will work. I did not think of, that I can take the players position / the vector from the player to the AI instead of just the AIs rotation or similar. That’s exactly what I was looking for.

My approach in the meantime was to create an EQS Context, in that calculate 5 positions on a straight line, perpendicular to the line between the player and the AI, and behind the player and then put them into a distance test. But it was no optimal solution, also because I could not score the distance to this points properly, but only filter them out.

Thanks again :smiley:

1 Like

Happy I could help you :slight_smile: