Alternative Path modifier causing "Very high penalty applied..." warning

Hi all

I have a gridgraph in my scene with a script attached to it that called AstarPath.Scan() once every 0.2 seconds. My seeker agents have the Alternative Path modifier attached to them. Everything was working fine and the agents pathed very nicely.

Since my game map has gotten larger, doing a full Scan() was too slow so I’m now calling UpdateGraphs() instead with a bounding box to determine which part of the graph should be updated. However, the Alternative Path modifier causes the following warnings;

“Very high penality applied. Are you sure negative values haven’t overflowed?”
“Penalty values this high could with long paths cause overflows and in some cases infinity loops because of that”

This leads to a stack overflow and the agent’s navigation eventually breaks.

The properties on the Alternative Path script are;

Priority = 2 (I get an error if I leave it at 1)
Penalty = 1000
Random Step = 10

The initial penalty on the GridGraph is set to 1.

The agents navigate fine if I remove their Alternative Path modifier (but it doesn’t look very good).

Any ideas?

Hm, yeah. The alternative path modifier relies on the graph not being changed completely when it is applied.
Calling UpdateGraphs with the default settings will clear all penalties on the nodes, so the penalties that the alternative path modifier added to it will be removed which will confuse the script.
Try to set the resetPenaltyOnPhysics on the GraphUpdateObject to false.

See http://arongranberg.com/astar/docs/class_pathfinding_1_1_graph_update_object.php#a0ce99169ed2be7e5cf342893991513a9

Thanks!

Thad did the trick. Much appreciated :slight_smile: