Hey, so I’m using a coroutine to check if a unit has a valid path during runtime. However, it appears to be incorrectly thinking that a valid path exists when one does not.
while(true) {
if (pathToCheck == null || pathToCheck.IsDone()) {
pathToCheck = ABPath.Construct(transform.position, attackTarget.transform.position, (Path p) => {
Debug.Log("Check path while attack callback");
Debug.Log(p.CompleteState);
if (p.error && !staticLookObject.IsObserved) {
Debug.Log("Can't reach target");
_cantReachTimer.Start();
} else {
Debug.Log("Can reach target");
_cantReachTimer.StopAndReset();
}
});
AstarPath.StartPath(pathToCheck);
}
yield return Timing.WaitForSeconds(0.5f);
}
Here you can see it in action - the AI On the right is trying to path to the player on the left through a closed door, the door was previously open but then closed and updated the grid around it
Even though the unit won’t go through the door, the AstarPath.StartPath() returns a CompleteState of Complete. Any idea what’s going on?
Thanks