Flee from multiple points

Hi! In the project, you have a FleePath script but it only takes 1 position to avoid. How can I make it avoid multiple positions. I tried passing a Vector3 array and looping through arrays like this:

for (int i = 0; i < avoid.Length; i++) {
aim += start - ((avoid[i]-start) * 10);

My spread is around 500000 because the nodeSize is 0.3. Sometimes this works if the agent only has 1 enemy to avoid, but if there are multiple enemies surrounding the area, it always takes a path going to one of the enemies, instead of avoiding them all. Also, sometimes when the agent and the enemy both flee from each other, they take paths across each other, so they intersect.

Any ideas please? Thank you very much!


This is unfortunately not possible with the default flee path, it can only avoid a single point.
You will have to copy that script and modify it to suit your needs.

Do you have any recommendations or suggestions on how to achieve this?

I’d recommend using the FleePath (configured to flee from your current position) and then also passing in an ITraversalProvider for which you add a penalty when the agent moves closer to the enemy positions.
See https://arongranberg.com/astar/docs/turnbased.html#ITraversalProvider