the flee task seems to fail at the edges of my terrain. Does anyone suggest something?

It looks like flee is trying to set a destination that it outside the navmesh and because the agent hasn't moved the task will return failure. As an enhancement you could add something similar to the Wander task where it first checks the navmesh with SamplePosition and only sets the flee destination if it is valid.
 
Top