How to tell if path to destination is blocked by cutout

I’ve been trying to figure this one out for a while with no luck. I’m trying to be able to tell when a destination is unreachable due to cutouts when using the Follower Entity. Help appreciated.

Hi

You may be interested in the IsPathPossible method: PathUtilities - A* Pathfinding Project

Hi, Aron. Thanks for the suggestion. I did find this and tried to make it work for me, but couldn’t figure out a way to specify which active graph I wanted it to use. I have an active graph which ignores the cutouts, so IsPathPossible was always returning true.

If you know of a way to specify which graph should be used, that would be extremely helpful. Here’s the code I was using.

var startNode = AstarPath.active.GetNearest(transform.position).node;
var endNode = AstarPath.active.GetNearest(target.position).node;

if (PathUtilities.IsPathPossible(startNode , endNode )) {
ai.SetDestination(target.position);
while (agent.pathPending) yield return null;
… other stuff
}

I think I’ve found a working solution for this, for anyone who runs across it in the future. It’s possible to select nodes on specific graphs by index using the following (where INDEX = the numeric index of the graph being used).

var startNode = AstarPath.active.graphs[INDEX].GetNearest(transform.position).node;

So if you want to use the second graph as it appears in the AstarPath component in the inspector, you would replace INDEX with 1.

1 Like

Great!

You can also use a graph mask like this:

var nn = NNConstraint.Walkable;
nn.graphMask = 1 << INDEX;
AstarPath.active.GetNearest(point, nn);