void updateAstar(int x, int y, bool obstacle) {
AstarPath.active.AddWorkItem(new Pathfinding.AstarWorkItem(ctx => {
var gg = AstarPath.active.data.gridGraph;
var nodee = gg.nodes[y * gg.width + x];
nodee.Walkable = !obstacle;
gg.CalculateConnections(nodee);
ctx.QueueFloodFill();
}));
}
Hello, I’m trying to update nodes manually one by one using the code above (due to ECS limitations). It works, but the ‘Hierarchical Node’ debug shows something weird. It looks like the nodes haven’t fully updated themselves.
There used to be an obstacle in that square area, then when I remove it, I call the code above to mark the nodes as walkable. But that doesn’t look right. Agents can move onto the newly walkable area, but their path is a little weird. They sometimes move around the former unwalkable area.
Apparently, ctx.QueueFloodFill(); is deprecated because the ‘HierarchicalGraph class’ is supposed to handle ‘pretty much all cases’. However, if I don’t call that function, I get the following:
I also tried calling
gg.GetNodes(node => gg.CalculateConnections((Pathfinding.GridNodeBase)node));
That seemed to properly update everything, however it takes forever to compute. Any suggestions?