Custom field for gridnode

The ITraversalProvider is very flexible for custom pathfinding, however it uses GraphNode whose Tag only has 5 bits to work with, which is not enough. I’d like to add more data to GraphNode, where can I put them to?

Just found there is a field called NodeIndex in GraphNode, maybe I can maintain a array in my project and save the extra field into the array.
here is the problem I’m not sure:

  1. The NodeIndex should not be changed after AstarPath.active.Scan();
  2. They are unique and compact (value start from 0 to gridNode count - 1)

Hi

The NodeIndex is globally unique, are uses low values. But it is limited by the number of nodes that have been activate at the same time at any point.
You may instead want to use node.NodeInGridIndex which is calculated as z*graph.width + x. So it is unique within the grid graph, and will go from 0 to width*depth-1.

1 Like