How can I calculate the furthest point from multiple actors locations?

Hello everyone! Been stumped on this all day.

I have made a system that makes an NPC animal flee from threat actors and it works well, the issue is when there are multiple, I want the NPC to calculate the “safest” route to get away from them, using the distance between each threat but I can’t get it to work.

I have tried merging vectors, adding them and normalizing in about every configuration I can think of. I am in over my head a bit but I feel so close to the answer but can’t figure it out.

Any help is greatly appriciated!

Hi Annak, welcome to community,

Think you don’t want to have the furthest point right? That one is quite easy I can show,
I think you want to have “best possible direction to escape”, (correct me if I am understanding it wrong)

If that’s the case.

ForEachActor->Normalize(NPCLocation-ThreatLocation) * 1/VectorLength(NPCLocation-ThreatLocation)

Make array out of this and add them up with a loop, is your escape vector.

However, this should be calculated individually per fleeing NPC, not once as a shared vector for a whole group. Otherwise, in edge cases, one of them can get a bad direction and run toward a threat instead of away from it.

If multiple threats at the same time, one approach is to simply average them get center,
or again we can weight the threats get a more meaningfull one,
or if you want truly a path, then you can spawn some navmesh modifiers and pathfind which is more heavier but more realistic end results would be.