I can’t get my NPCs to perform a move away task for the life of me. AIMoveTo works just fine when it wants to, but every trick I have tried only results in the Pawn moving TOWARDS the target instead of away from it. I am using AI Perception and BPs, without the BT or EQS. The NPCs can “see” each other but deer aren’t supposed to move towards wolves on sight.
Hi, if you want the AI to move away from an actor A, choose a point that the AI can reach and that has some distance from A and where moving towards that point will not lead through A. After you choose such a point (however you want to do that, EQS would be suited for that but you could also do it with custom blueprints, would only be a bit like reinventing the wheel) use MoveTo with that point as target.
I recommend calling Move to Actor as it does not need tick. The AI will move to the actor until it reaches it. One call works fine.
Depending on how you want your AI to flee, you can tell it to move elsewhere with Get Random Reachable Point in Radius. Though this is unpredictable. Another option is to store their start location when on begin play and tell them to Move to Location when you need to.
As for when, you can use On Movement Update and compare the previous and current movements. Or else set a boolean for whether or not they are in follow/flee mode and check that on a tick. Tough a timer is better because it does not need to be frame perfect. A looping timer of 0.1 is just as accurate compared to a tick of 0.003. You can also stop and start timers with events for when you need this check to occur instead of ticking.
Without knowing how your AIPerception is setup as, there could also be issues with them constantly “sensing” the player on sight or lost sight. Turning off perception could help so that they are not detecting while they are fleeing.
Have you looked into EQS?