I made a test room for flee path: an unit with AIPath following its target, another with a custom class inherited from AIPath (changes from basic AIPath to FleePath by pressing a button)
I find quite often my fleeing unit trying to run through the seeking unit even though it should be able to circle around the room and has more move speed.
In this picture the fleeing unit is on the right, it should go down to flee but tries to cross the other unit instead.
Most of the time it flees correctly but it has these moments, I am not sure how to take care of…
Btw this is how I implemented a change between follow and Flee :
public override void SearchPath()
{
if (isFeared)
{
if (fleePathApplied)
{
return;
}
Debug.Log($"Calculating Fleepath");
fleePathApplied = true;
// Create a path object
FleePath path = FleePath.Construct(transform.position, destination, fleePathLength);
// This is how strongly it will try to flee, if you set it to 0 it will behave like a RandomPath
path.aimStrength = 1;
SetPath(path);
}
else
{
base.SearchPath();
}
}