I switched aiPathBase to use the StartMultiTargetPath function instead of StartPath and it seems to work except now I’m getting the “you are releasing a path which has not been claimed with this object” error. If I remove the “if (path != null) path.Release(this);” line from the callback then the error goes away but I’m not sure this is the proper way to handle this. Anyone know?
Hi
Which callback are you using?
The MultiTargetPath can send two types of callbacks, one when the whole path is complete and another one which is called for each sub path.
The OnPathDelegate I think (not a super great programmer here) - seeker.StartMultiTargetPath(transform.position, targets, false, OnPathComplete);
I basically left all the original code the same except commented out a few pieces in OnPathComplete:
public virtual void OnPathComplete(Path _p)
{
ABPath p = _p as ABPath;
if (p == null) throw new System.Exception("This function only handles ABPaths, do not use special path types");
canSearchAgain = true;
//Claim the new path
//p.Claim(this); <--Commented out
// Path couldn't be calculated of some reason.
// More info in p.errorLog (debug string)
if (p.error)
{
p.Release(this);
return;
}
//Release the previous path
// if (path != null) path.Release(this); <--Commented out
//Replace the old path
path = p;
//Reset some variables
currentWaypointIndex = 0;
targetReached = false;
}