Force an enemy with a ranged weapon to keep their distance from the player.

Hello, I’m new to UE and I’m trying to make the enemy move some distance away from the player if he comes close. I tried to do something, but the enemy does not see and avoids the obstacles behind him and gets stuck there. I tried to do it through EQS, but it also doesn’t work as it should - if the enemy hits a wall, he runs straight towards the player, without trying to turn sideways. The enemies behaved well in Half-life 2 (those who played will understand). Does anyone have any ideas on how to properly think through the logic in my case?

hello.
When using EQS,do not generate points in a full circle area around player.

generate them in a frustum (cone?)area in the direction from player character to the enemy.

so it excludes the area behind the player.

I don’t use EQS a lot ,but in my memory it can achieve this.

I tried, but there is a problem, if the player turns away from the bot (turns his back), then the cone is also transferred in the direction of the player and the bot begins to run forward of the player. If it were possible to make the cone always look from the player to the bot…

this is how to get the cone’s direction

Thank you, but could you tell me how to grab the cone from the EQS in order to deploy it?

I just did a experiment and found that the cone and circle don’t generate locations behind walls.

so I used a donut instead.

see if it’s close to what you need.

what it does is generate a circle of points(use donut) around the player and choose the closest point to the enemy AI.
here’s how it set up.



Not exactly, I downloaded the Lyra project from epic games and they have it perfectly implemented through EQS

1 Like


not sure.i feel it’s similar…however,Lyra’s definitely going to have more details and more complicated…it’s a big project…you could directly copy the codes from Lyra if you like it. :smiley:

Did you have this happen with the donut in the post above, what’s in the video now?

exact the donut…when player is in range.just run the donut EQS.it will generate a location.then have the Ai move to that location.

I did this with a donut, randomly set it to 5% of the best point on the output and it works very well. Only I don’t understand the moment in EQS in the context of “EnvQueryContext_Querier”. What is he referring to?

Querier is basiclly referring to the AI itself,who runs the behavior tree&the EQS.
and context class is eveything else. kind of like “getter”, it gets information outside. in this example,it gets the player.

PS; if you use this method,you might need to set the dount range slightly larger then the AI’s attack range.otherwise it might have some problem.
how large?well,testing is needed :joy:

Thank you so much for your help. You really helped me.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.