Hi, I would use EQS for this. So first you should follow the quick start guide for EQS step by step: Environment Query System Quick Start | Unreal Engine Documentation
What I would then do for your setup: When the bot is too close (or too far away) to the player it calls an EQS Query in the behaviour tree to find a new point, with line of sight on the player, and moves to that point
-
Create a new “Environment Query”
-
First you would need a generator to generate possible target locations for the bot. Doc: EQS Node Reference: Generators | Unreal Engine Documentation
Depending on how you want to do this you could generate a circle (“Points: Circle”) around the player (with your desired distance as radius) and the let the bot move to the point closest to it (I think that would be the easiest way to keep a fixed distance to the player but you also may try using a grid).
- The Circle generator needs to know where the center the circle is. For that it needs a context Doc: EQS Node Reference: Contexts | Unreal Engine Documentation
I would make a new custom context and override the “Provide Single Actor” function and return the player character.
- Now the EQS query will generate points around the player, you may want to filter or score them. That is done by tests. Doc: EQS Node Reference: Tests | Unreal Engine Documentation
I would use a trace test to filter by visibility (the context would be the player, so it will do a trace from the point to the player and checks whether it the trace hits something on the way). And for this, in the context you used to get the player you may need to override the “Provide Single Location” function and return the player location there.
And Pathfinding to score the point by the pathlength from the bot (so prefer lesser pathlength and the context would be the querier that’s the bot)


