Download

AI - Stop and resume MoveTo depending of player distance with the NPC

(Sorry if my English is a little rough)
Hi. I’m making a simple NPC which leads the way to the player but also waits for you if you don’t follow her or you’re too far. I took inspiration from Until Dawn, here is an example of how the female character is leading the way but when the player gets distracted it waits until you get close again and then continues it’s path.
(Minute 26:55)
https://youtube.com/watch?v=ZJ8odEjorfI

I created this on the Character Blueprint using an sphere collision to start the NPC navigation, a navmesh, TargetPoint which is the variable “LeadTheWay” and a macro. I was able to make the navigation stop if the player is far from the NPC but I don’t know how to make it resume when you get closer again.

Christine 19_1_2021 05_46_38 a.m..png
Christine 19_1_2021 06_05_25 a.m..png

Hi, first of I would suggest that you switch to use behavior trees, that will make it much easier for you instead of trying to reinvent the wheel in blueprints from scratch.

With behavior trees what you want to do will be very easy. Your highest priority task would be waiting for the player (just executing a Wait) and you would put a decorator on top (which checks the distance between the AI and the player, so that you only executing the Wait if the player is further away than X distance from the player). Second in priority would be a MoveTo with your TargetPoint as location.

That will result in the AI waiting for the player, if the player is further than X distance from it, otherwise it will move to TargetPoint.
[HR][/HR]
So I would suggest that you follow through this here and reimplement it step by step to get a feeling for behavior trees Behavior Tree Quick Start Guide | Unreal Engine Documentation

Afterwards you can look through all those three Essentials here Behavior Trees | Unreal Engine Documentation

Thank you, this was very helpful!