Support Forum

Path takes the more expansive way

Hi,

I have two graphs :

  • graph 0 layered grid graph with default penalty to 100001(debug value)
  • graph 1 point graph with default value of 0 ( nodes are add in runtime)

When I ask for a path, I set tag penalties like so : default 999999, road 0

So my problem is, as show screens, my agent after a recalculation receives a path traveling inside graph 0 which have a high penality in place of graph 1.

My goal here is to have the default terrain ( graph 0) and have roads (graph 1)( or at least desired path) use before the ground.

I try multiple settings but no one work

Penalty view :

Good path before recalculation :
goodPath

Problematic path :
path

Ok, I understand a little bit more the problem.

Algo uses NNContraint to chose the start node then use penalities and tag settings from path to open node.

Why this differences ?

Because of that, A* takes a node from my grid graph at the place of my point node because with movement grid graph node is a little closer and doesn’t care about penalities of path

Hi

Having two graphs like that will make the pathfinding kinda confused because it’s not always clear which graph to use. Since your game looks very tile based I would instead recommend that you put the penalties on the graph itself.

You can do this using for example using a texture (a feature only available in the pro version, see https://arongranberg.com/astar/docs/gridgraph.html#textureData)
Or you can do it using e.g. the GraphUpdateScene object (though this is kinda brittle), or or just manually changing the graph (see https://arongranberg.com/astar/docs/graph-updates.php#scripting)