Test if Path possible & meanwhile continue moving along current path

Hey, I would like to manually test if a path exists from A to B, and doesn’t go through myNavTag

I don’t want to ask Seeker to do this, because it would stop its current path.
It’s desirable for the Seeker continue to move along its current path.

I would assume something like this:

p = ABPath.Construct( startPos, 
                      destination, 
                      MyCallbackToVerifyPath );

 p.enabledTags = 1;//try to find only on nav-tag traversable by player.

however, this seemsi t’s too late to set tags, as the path is already constructed.

And it doesn’t seem possible to ask the AstarPath to construct a path using the Constraints

Actually, I think AstarPath.StartPath is what I needed

You may be interested in PathUtilities.IsPathPossible. Note though that the IsPathPossible method call with a tag mask parameter has to do a full search of the graph, which may be slower than using an ABPath if your graph is very large.

1 Like

Thank you,

Is there a way to limit the distance beyond which IsPathPossible() won’t bother searching?

IsPathPossible does take a list of nodes, but it’s for start and all destination nodes, not for “all nodes that are allowed to be searched-through”.

If it were the case, I could use PathUtilities.GetReachableNodes() or a distance limit. It’s just that my navMesh has a lot of triangles, something like a 2000 for a mobile device, and I indeed need to search with a tag_mask

How should I approach this?

Hi

You could use PathUtilities.BFS I suppose.

Something like this:

using System.Linq;

var nodes = ...;
int range = 20; // In number of nodes away from the start that it will search
// Find *all* nodes within 20 nodes from the start node
var nodesWithinRange = PathUtilities.BFS(nodes[0], range, tagMask);
// Check if all the nodes were in that list
return nodes.All(node => nodesWithinRange.Contains(node));

Note that using PathUtilities.GetReachableNodes() would not optimize anything because those are exactly the nodes that IsPathPossible will search through in the worst case anyway (in fact, IsPathPossible uses GetReachableNodes under the hood).

1 Like