I am using a constantPath to find all the surrounding nodes of a specific node. Unfortunately, this does not return unwalkable nodes. Is there a way to do this?
Hi
You’ll have to go through these manually:
static readonly int[] hexagonNeighbourIndices = { 0, 1, 5, 2, 3, 7 };
List<GridNodeBase> GetNeighbours(GridGraph graph, int x, int z) {
var neighbours = new List<GridNodeBase>();
for (int i = 0; i < hexagonNeighbourIndices.Length; i++) {
var dx = neighbourXOffsets[hexagonNeighbourIndices[i]];
var dz = neighbourZOffsets[hexagonNeighbourIndices[i]];
var nx = x + dx;
var nz = z + dz;
var node = graph.GetNode(nx, nz);
if (node != null) {
neighbours.Add(node);
}
}
return neighbours;
}