How do you make AI to stop following you after a certain distance?

I’ve been trying to get my AI (using third person character blueprint) to stop following me after he’s out of range of my pawn sensing but I can’t figure it out. Any help would be appreciated! I can provide a screenshot of what I have so far if requested.

Screenshot would be good

on the way

What’s happening exactly is when my first person character gets in front of the AI’s pawn sensing it starts to chase me but when I’m out of range of the pawn sensing it still chases me. The only way it goes back to patrolling is if you go around the back of it.

to which ones?

The AI just seems to ignore me now that I set it to 500

Have you tried checking the box “stop on overlap”?

And increase the “acceptance radius”? “5” is super small

try increasing the acceptance radius to something like 100 (i see your move radius is only 1200) first and see if that helps, on both AI Move To nodes

yea that was my bad, i didn’t realize your search radius for random movement was only 1200…that is a comparatively large proportion so i changed my initial comment to acceptance of 100.

Also I just remembered, I think on pawn sensing in the details menu there is an option for “lose sight radius” i would check that out, it might be further away than you think

nope, just looked, must have been a variable I made. So what you can do is set a timer and every like 1 sec or so, have it check the distance from player to AI and if greater than sight radius tell it to “roam”

I don’t think that’s the problem, it seems to just be making the distance in which the AI reacts farther. 5 seems good because it reacts when the character gets inside the pawn sensing radius.

I’ll check that out

I couldn’t find “lose sight radius” in pawn sensing.

How would I do that? if that involves a behavior tree I can’t do those … :slight_smile:

I’ve been trying to create this for a while and I can’t figure out how to set everything up, this set timer by event thing is new to me.

no, nothing that crazy. Just use “Set timer by event” thats hooked up automatically to a custom event, call it what you like (Sight Check) whatever, from that get world location of player and AI, use a “get distance to” node and check the output against whatever your “sight” radius is in the pawn sensing. If greater than sight radius the player is too far away, AI should roam, so set “In Range” to false if that comparison is true.

below ill post a picture showing the basics of the setup with a timer. if you use the setup in the pictures the timer will call the event checkdistance to player every 1 sec and will continue doing so. you may want to add in a way to stop the timer but this will get you started.

alternatively you could use ai perception for this issue as it has more options for when you want the ai to lose sight of and forget a target. below in the second picture is some of the options with ai perception.

233981-capture2.png