Hello,
My agent seems to ignore the red blocks that I placed using a work item, i basically looped through all the nodes and for every node i checked its position against my grid system and checked if the height at that position is below zero and assigned it not walkable.
However even though the gizmos clearly show that the area is not walkable my agent still moves to it if the target is close to the shoreline: Astar Support - Album on Imgur
Any idea whats causing this? maybe the way i add the constraints is incorrect?
Heres the code
private void ApplyNavConstraints()
{
LayerGridGraph gg = AstarPath.active.data.layerGridGraph;
AstarPath.active.AddWorkItem(new AstarWorkItem(ctx =>
{
for (int z = 0; z < gg.width; z++)
{
for (int x = 0; x < gg.width; x++)
{
GridNode node = gg.nodes[z * gg.width + x] as GridNode;
if(node == null) {continue;}
Vector3 nodePos = (Vector3) node.position;
SquareCell cell = grid.GetSquareCellFromPoint(nodePos.x, nodePos.z);
node.Walkable = node.Walkable && !cell.isWater;
}
}
}));
AstarPath.active.FlushWorkItems();
}