How to get the six neighbor nodes in hexagonal map

The GraphNode.GetConnections() only return the walkable neighbor nodes, I want to get all the six nodes

Hi

You can use something like:

int[] hexagonNeighbourIndices = { 0, 1, 5, 2, 3, 7 } 
var graph = node.Graph as GridGraph;
for (int i = 0; i < 6; i++) {
   var nx = node.XCoordinateInGrid + GridGraph.neighbourXOffsets[hexagonNeighbourIndices[i]];
   var nz = node.ZCoordinateInGrid + GridGraph.neighbourZOffsets[hexagonNeighbourIndices[i]];
   
   // Will be null if the neighbour is outside the graph
   var neighbour = graph.GetNode(nx, nz);
}

it works, thanks.
I think it is okay to reorder the hexagonNeighbourIndices?
such as int[] hexagonNeighbourIndices = { 0, 1, 2, 3, 5, 7 }

Sure. No problem.

See also GridNode - A* Pathfinding Project