I’m doing a bunch of calculations on a GridGraph in editor mode. I recently made an array the same size as the gridGraph.CountNodes() return, but I kept getting an IndexOutOfRange error until I changed the array size to gridGraph.CountNodes() + 1.
When I run this line
Debug.Log(“Node at index 0. NodeIndex:” + gridGraph.nodes[0].NodeIndex + " has x " + gridGraph.nodes[0].XCoordinateInGrid + " Z: " + gridGraph.nodes[0].ZCoordinateInGrid);
I get this output:
Node at index 0. NodeIndex: 1 has x 0 Z: 0
When I do the same, but for nodes[1] I get:
Node at index 1. NodeIndex:2 has x 1 Z: 0
And when I query 0,0:
Debug.Log("Index of 0,0: " + gridGraph.GetNode(0, 0).NodeIndex);
I get a NodeIndex of 1 for that node…
When I use gridGraph.GetNodes(node => {…}) no node has a NodeIndex of 1.
So they’re off by 1. Is this a bug?