How to access Layer index of a Node

Hi, I am trying to get a layer index of a LevelGridNode but it returns 0 for no apparent reason (at least for me).

I’ve set up a small example to illustrate it:

Each cube (red and grey) has a script attached:

public void DebugClosestNode()
    {
        var node = (AstarPath.active.GetNearest(transform.position).node as LevelGridNode); 
        Debug.Log($"Graph LayerCount {AstarPath.active.data.layerGridGraph.LayerCount}");
        Debug.Log($"Node Position: {node.position}. Coordinates: X:{node.XCoordinateInGrid}, Z:{node.ZCoordinateInGrid}, Layer: {node.LayerCoordinateInGrid}");
    }

which is triggered by a keyboard press. The output on the console is as follows:

Node Position: (11.3, 0.6, -2.5). Coordinates: X:20, Z:6, Layer: 0
Node Position: (11.3, 5.6, -2.5). Coordinates: X:20, Z:6, Layer: 0

So for me there is something wrong. Can anyone confirm that it is a bug indeed? Or am I doing something wrong?

I am using beta version 4.3.26.

Thanks!
Yes. This was indeed a bug in the beta version.
I have fixed this locally and the fix will be included in the next update.

1 Like