i’ve set aiPath.autoRepath.mode = AutoRepathPolicy.Mode.Never; and manually search the path for my agent. I’ll invoke the StartSearch to recalculate the path after graph is changed. and if currently a path is being calculated then I’ll set needSearchAgain=true so that when the path is completed I’ll calculate it again by delegate of TrySearch(). the problem is sometimes when the callback function is invoked the aiPath.pathPending==true. so what’s the best way to recalculate the path for aiPath.pathPending == true
private bool needSearchAgain;
seeker.pathCallback += TrySearch;
private void TrySearch(Path ignore)
{
if (needSearchAgain)
{
Assert.IsFalse(aiPath.pathPending);
needSearchAgain = false;
aiPath.SearchPath();
}
}
protected void StartSearch()
{
if (aiPath.pathPending)
{
needSearchAgain = true;
}
else
{
aiPath.SearchPath();
}
}