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.
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.
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:
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.
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.