Custom travel cost

Hi,

Im looking for a way to customize the cost of traversing nodes while pathfinding. As cost needs to be calculated while evaluating nodes I cannot store it in the graph.

GetTraversalCost in Path seems to be a good candidate for overriding but its not virtual, and I dont like modifying your framework to prevent complications while upgrading. Could you make it virtual ?

Bump, or is there some functionality intended for this that im missing ?

Hi,

The problem is that I only want to adjust penalties for nodes considered for pathfinding.

In this case I want the penalty be higher if an enemy can see the node, but I dont want to calculate every single node visible by enemies. Im using a grid graph but even with a navmesh it would be a big waste.

So I want to hook into the pathfinding system to use different penalties while calculating, but there is no clean way of doing that from what I can see.

Hi

You can add penalties to your nodes.
A penalty on a node will be added as an extra cost for traversing a specific node. You can also mark nodes with specific tags and have the cost for traversing a tag be agent-dependant.

See http://arongranberg.com/astar/docs/graph-updates.php
http://arongranberg.com/astar/docs/tags.php
http://arongranberg.com/astar/docs/calling-pathfinding.php#graph-data

Hi

The easiest way would just be to mark it as virtual. It is not marked as virtual right now because of performance reasons (that method is called A LOT and even a virtual function call costs a bit).

It can be done cleanly, but in far harder way by overriding the graph to change the type of node it creates from TriangleMeshNode to a custom class MyCustomNode which would inherit from TriangleMeshNode.
Your custom node class would need to override UpdateG method and the Open method and change the places where the G score is calculated.