HI @aron_granberg!
I have stumbled upon a really weird issue and cannot move forward without your assistance. My case is very similar to the turn-based utilities example from the documentation.
I have units that can traverse the graph, the units are blocking the nodes that are on. Simple.
I am using the graph with 8 connections and my problem emerges when I try to move a unit when it is surrounded by units in a pattern like this:
☐ E ☐
E X E
☐ E ☐
X - unit that is being controlled
E - enemy that is blocking the node
The unit is using a traversal provider which excludes the nodes that are being occupied by enemies. When that happens the pathfinding fails, despite the graph being configured to use 8 connections and it is scanned properly (i.e. the connections are there, visible in scene view). When not using a custom traversal provider the path (using diagonals) is calculated without any issues).
The traversal provider code is super simple, only checks for the blocked nodes, but maybe I am missing something obvious there:
public class ExtendedTraversalProvider : ITraversalProvider
{
public List<GraphNode> excludedNodes = new List<GraphNode>();
public bool CanTraverse(Path path, GraphNode node)
{
if (excludedNodes.Contains(node))
{
return false;
}
else
{
return DefaultITraversalProvider.CanTraverse(path, node);
}
}
public bool CanTraverse(Path path, GraphNode from, GraphNode to)
{
return CanTraverse(path, to);
}
public uint GetTraversalCost(Path path, GraphNode node)
{
return DefaultITraversalProvider.GetTraversalCost(path, node);
}
}
I have prepared an isolated reproduction project ready to be shared. Please let me know how you would like to get it shared with you.
Here is the video demonstrating the issue: https://streamable.com/m00yzt
I am using unity 2021.2.14f1 with Pathfinding Project 4.3.48.