How would you go about adding Flee to AIPath?

I think I’ve given up on writing my own pathing logic but need to add the ability for my entity to Flee. Is there an “easy” way to add that to AIPath?

Hi

You can do it like this:

// Get the attached AIPath/RichAI/AILerp script (all implement this interface)
ai = GetComponent<IAstarAI>();

// Disable the automatic path recalculation
ai.canSearch = false;

// Make the AI flee from the enemy.
// The path will be about 20 world units long (the default cost of moving 1 world unit is 1000).
var path = FleePath.Construct(ai.position, pointToAvoid, 1000 * 20);
ai.SetPath(path);

The AI’s own path recalculation code needs to be disabled because otherwise it will quickly override your flee path with a new one that goes to the normal destination.

Great, thanks for the information!