A* Pathfinding Project

Path failed on runtime PointGraph


I’m having issues with a PointGraph generated at runtime. The graph generates fine and looks correct in the scene view and the nodes and connections show up right but the path calculation fails. Any thoughts as to what this could be? Anything would help, I’ve spent hours trying to figure this out.

Path Failed : Computation Time 0.00 ms Searched Nodes 0
Path Number 40 (unique id)
AstarPath:LogPathResults(Path) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:797)
AstarPath:<InitializePathProcessor>m__12(Path) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1202)
Pathfinding.<CalculatePaths>c__IteratorD:MoveNext() (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:523)
Pathfinding.PathProcessor:TickNonMultithreaded() (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:134)
AstarPath:Update() (at Assets/AstarPathfindingProject/Core/AstarPath.cs:825)


I have been able to get past the above issue. It was caused by me overriding the “nodes” array using my own node type.

So in my custom graph subclassing PointGraph I had this:

public MyNodeType[] nodes;

Then to make things worse I added the new keyword I think to hide the warning about “hiding” the original variable and things really got weird.

public new MyNodeType[] nodes;

Now AstarPath thought nodes was null but I could see the nodes array had nodes in it. Even in the debugger it would show incorrectly.

Now I’m just keeping the original array and casting to my type as needed.


That will just create a new field which has no relation to the other field named ‘nodes’ in the base class. They will not share memory at all. Adding the ‘new’ qualifier will just hide the warning but not change the fact that they are different fields.


Yep, once I removed that things got much better and my point graph works. Now I have a new problem related only to connections between my PointGraph and the GridGraph. For some reason node.NodeIndex is returning -1 when a path goes between the two, here ind is getting set to -1

	public PathNode GetPathNode (GraphNode node) {
		// Get the index of the node
		int ind = node.NodeIndex;
                return nodes[ind >> BucketSizeLog2][ind & BucketIndexMask];

What I have is my point graph in the grid graph. I disabled the grid graph nodes that are overlapping the point graph. I made the point graph magenta color to show the structure.

I can walk around the point graph and walk around the grid graph but things fail when i try to go between.

And the console:


Looks like this has something to do with me hanging on to node instances between scans. I was doing that to “cache” some of the connections but it appears that is causing issues.

I think it has to do with this code, which gets called before a Scan is performed:

	internal void Destroy () {
		//Already destroyed
		if (Destroyed) return;


		if (AstarPath.active != null) {
		nodeIndex = -1;

So a solution here is to not try to hold on to any nodes or connections between scans or save them in another form not relying on GraphNode implementation.

Any recommendations for a caching solution?



Yeah, that’s a bad idea. The nodes will be destroyed.

It’s hard to recommend any approach since I do not really know what you are trying to accomplish, but saving the information in some other form should work.