How to move node of GridGraph on runtime?

I know that GridGraph creates what it says - a grid.

But can I move SOME nodes or just one node slightly with code during runtime?

Something like:

GridGraph.SomehowGetNode.setNewCoordinates(20,0,14);

Thanks

Hi

You can technically move a grid node, it may throw off some algorithms a bit (like linecasting on a grid), but generally I think it should work.

// We must only update the graph when it is safe to do so
// The callback will run once the pathfinding threads have been stopped
AstarPath.RegisterSafeUpdate(() => {
    var node = AstarPath.active.GetNearest(somePosition).node;
    node.position = (Int3)new Vector3(20,0,14);
}

// Optionally force the above callback to run immediately
// AstarPath.active.FlushThreadSafeCallbacks();
1 Like