Function GridGraph.CalculateConnectionsForCellAndNeighbours

CalculateConnectionsForCellAndNeighbours (int x, int z)

Calculates the grid connections for a cell as well as its neighbours.

Public
void CalculateConnectionsForCellAndNeighbours (

int

x

int

z

)

Calculates the grid connections for a cell as well as its neighbours.

This is a useful utility function if you want to modify the walkability of a single node in the graph.

AstarPath.active.AddWorkItem(ctx => {
var grid = AstarPath.active.data.gridGraph;
int x = 5;
int z = 7;

// Mark a single node as unwalkable
grid.GetNode(x, z).Walkable = false;

// Recalculate the connections for that node as well as its neighbours
grid.CalculateConnectionsForCellAndNeighbours(x, z);
});

Warning

If you are recalculating connections for a lot of nodes at the same time, use RecalculateConnectionsInRegion instead, since that will be much faster.