Update a node

Hi Aron,

I would like to update a node during runtime in a gridgraph scheme without using a gameobject, no problem to localize the node with the AstarPath.active.GetNearest() function but how can I set it to walkable or unwalkable easily after?

I can see that the AstarPath.active.UpdateGraphs() is only for bounds and there is the function UpdateNodePositionCollision() that could help me but I do not know how to use it.

Could you tell me if I’m in the right direction?

Thanks again for your work, two weeks that I’m working with your tool and I’m really satisfied.

Cizia

If you get the node object, you can simply set the walkability on it:

Node node = AstarPath.active.GetNearest (...);
node.walkable = false;

However this can cause weird issues if a path is being calculated at the same time, so you should make sure to call it as a safe time:

AstarPath.RegisterSafeUpdate (delegate () {
     Node node = AstarPath.active.GetNearest (...);
     node.walkable = false;
 },true);

I think the above syntax is correct, but I just wrote it in the browser so it might have syntax errors.
See http://arongranberg.com/astar/docs/class_astar_path.php#ab2449a5036d440ca6b1763f176cb5836

PS: Want to support the development of the A* Pathfinding Project. Give it a rating in the Unity Asset Store and/or write a nice review about it. :smiley: