Update connections cost

Hi is there a better way to update connection cost between two nodes than deleting the connection and adding a new one with the correct cost.

Hi

What method are you referring to? Code or some component?

Oh sorry.
For now, to update a cost between two point I do something like this :slight_smile:

point.RemoveConnection(other);
point.AddConnection(other, (uint)new_cost);

Is there a simpler way to modify the cost?

Hi

The AddConnection method will for most nodes simply update the cost if AddConnection is called with a node that it already has a connection to. The exception are GridNodes which cannot do that since normal grid connections are not stored on each node for lower memory usage (that would be wasteful since in they are always identical).
See the documentation here: http://arongranberg.com/astar/docs/class_pathfinding_1_1_point_node.php#a7737fe4ce16263109be7c0040bd001da

1 Like