Exclude area from EQS-based pathing

I am trying to get an AI actor to flee from a player actor. I have set up the AI actor with vision perception to detect the player actor which activates an EQS query which does a very good job of finding hiding spots from the player actor. However, based on the environment the path from the AI actor’s current position to the hiding spot often takes moves the AI directly at or in the path of the player actor. This is a big problem because the player’s goal is to “catch” (cause a collision) between the player actor and the AI actor, so running toward the player, even if it is to eventually go to a hiding spot, defeats the purpose.

My first thought was to clamp the distance so it wouldn’t take long routes (which usually took the AI into the player’s path), but that is absolute distance between the AI and the hiding spot, not the distance of the path. My second thought was to find a way to block pathing through an area surrounding the player actor, but pathing is handled through the moveto function, not EQS.

So I’m at a bit of a loss. Basically the idea is the AI should always move away from the player and if the only option to get to an eligible hiding spot is to move past the player, it should just not move. Any help would be greatly appreciated.

Not the most elegant or performance friendly, but you could have a vision cone shaped actor attached to the player’s camera, and add a Nav Modifier Component to it with a nav area with very high cost, so the moving AI will always try to avoid walking into the player’s vision cone (though I think only box shaped volumes work for the Nav Modifier component, so you might have to settle with a huge box instead).

More info here: Navigation Components | Unreal Engine Documentation

Not quite, since my player controller is using the navmesh itself. However, thank you for putting me on the right track; the navmodifier volume is not a scene component, so putting it on my actor did the job but the null area didn’t move with the player.

But poking around for that led me to this post by Epic’s AI designer, that navmodifier volumes shouldn’t be used for this purpose, but instead the “can affect navigation” setting for actors and setting the capsule component to navNull to create a moving non-pathing zone around the player actor. This worked well but since the player actor uses the navmesh for navigation, this led to some extremely bizarre behavior. So I went looking for ways to create a navmodifier that only applied to specific actors.

I couldn’t find anything like that, but I did find this post about nav filters. It’s not particularly elegant, since the filters only apply on a per-blueprint-block basis, but I set up a query to exclude a custom navmesh class I created (and set my player actor to), then added the query as a filter to my AI Move To Location block. That did it!

1 Like

Oh wow, that’s a pretty creative work around. Glad you were able to get it working though!