Hey,
I like to check if the path is reachable before using sending the unit on its way. Currently Im using the “AIPath” but I cant find a way to catch if the path is not reachable.
However, I can catch errors with the “Seeker”. I made a temporary solution like this:
private AIPath pathfinding;
private Seeker seeker;
private IEnumerator SearchPath(Vector3 taskPosition)
{
var path = seeker.StartPath(taskPosition, transform.position);
yield return StartCoroutine(path.WaitForPath());
if (!path.error)
{
pathfinding.canSearch = true;
pathfinding.isStopped = false;
// Set destination
pathfinding.destination = taskPosition;
isMoving = true;
}
else
{
onTaskDone(false);
}
}
However, the path gets (logicly) calculated two times now.
I tried somting like
pathfinding.SetPath(path);
However, this gave me an error:
My question, is there a clean way to first check if there is a path (no error) before sending the AIPath, without calculating the path twice.