Using new feature Traversal Provider

Hi, I’m trying out the new traversal provider feature. I’m facing a problem that I don’t know if it’s a missing feature or is a misuse.

Without traversal provider, when calculating a path to a point that it’s in a grid node not walkable, by default the resulting path ends in the nearest walkable node.

But when using a traversal provider (I’m using the example implementation, SingleNodeBlocker and BlockManager) the result of calculating a path to a grid node that has been blocked by SingleNodeBlocker doesn’t return a path to the nearest walkable node, instead, I get a Path Error (because can find any targetable node).

Can you please give some directions to resolve this problem?
Thank you very much,
Leo.

Hi

I’m glad you are using the new feature.
Unfortunately this is a rather tricky problem. The issue is that for a normal path to be able to calculate the path to the closest point it can actually reach, the graph needs to be pre-processed which is an (relative to a path request) expensive operation that involves iterating through all the nodes in the graph.
The only way it is possible to determine that the closest node has in fact been reached without this pre-processing step is to simply search through all nodes that the path can possibly reach, which may be very slow depending on how large the graph is. That is why by default this is not done in most cases.

I might have to work on providing something a bit more out of the box for this scenario.

You are getting the “Searched whole area but could not find target” error, right?
If so, you should be able to do something like this

var path = ABPath.Construct(...);
path.calculatePartial = true;
seeker.StartPath(path, ...);

However I was recently notified that the calculatePartial feature (which is just experimental at the moment, as is also noted in the documentation for it) has a bug. Around line 555 in the ABPath.cs script you will see some lines that look like this:

// Any nodes left to search?
if (pathHandler.heap.isEmpty) {
	Error();
	LogError("Searched whole area but could not find target");
	return;
}

You will need to change that to

// Any nodes left to search?
if (pathHandler.heap.isEmpty) {
	if (calculatePartial && partialBestTarget != null) break;
	Error();
	LogError("Searched whole area but could not find target");
	return;
}

This fix will also be included in the next update.