How to access nodes of a GridGraph by index?

The grid on my game is represented by a 2D array of tiles, so I want to know if it is possible to access the nodes of a GridGraph using its index, like [Width, Depth], so I can change the properties of a node directly. How do I get the GridGraph instance and How do I access its nodes? Thank you.

Sure

`
// Get the grid graph
GridGraph gg = AstarPath.active.graphs[0] as GridGraph;
// alternatively gg = AstarPath.active.astarData.gridGraph;

GridNode myNode = gg.nodes[z*gg.width + x] as GridNode;
// If you are using the beta, the “as GridNode” is not needed
`

If you want to /change/ the properties of the node, you can either do it directly whenever you want, but beware that if you are using pathfinding at the same time, you might get corrupt paths back (it’s not nice to change the graph while pathfinding on it).
Or you can download the beta and do something like
AstarPath.active.AddWorkItem(delegate (bool force) { ... do the above stuff here return true; }));
The wrapping will make sure that it does not interfere with other pathfinding stuff.
If you are changing walkability of the nodes, I strongly recommend calling
`
// If you are using the beta ( >= 3.3.5)
// This one will save performance if several updates are done at the same time
AstarPath.active.QueueWorkItemFloodFill ();

// Otherwise
AstarPath.active.FloodFill ();
`
to make sure pathfinding still works correctly.