I’m creating a top-down 2D game where you can mark tiles(nodes) to dig your way out. I’m currently using this code to make it possible for the AI to walk once a tile has been dug:
AstarPath.active.AddWorkItem(new AstarWorkItem(ctx => {
var makeWalkableNode = AstarPath.active.GetNearest(cellPosition).node;
makeWalkableNode.Walkable = true;
var gg = AstarPath.active.data.gridGraph;
gg.GetNodes(node => gg.CalculateConnections((GridNodeBase)node));
ctx.QueueFloodFill();
}));
However, when they reach a certain distance from the center of the grid it skips a node.
The console prints the “makeWalkableNode” position once it has been dug, which you can see skips a step for some reason. Scanning the whole graph with AstarPath.active.Scan(); “fixes” this problem since the uncolored area connects, but is not good for performance.
If I change the Grid Graph’s width and height this “node skip” happens earlier. Doesn’t matter which way I dig, the skip forms a grid pattern.
I’ve tried reading the scripts and documentation to find if a single Grid Graph is divided into subgraphs with 1 node’s border, but wasn’t successful.