Penalty for some nodes has been reset while this modifier was active

Hi,

When I’m destroying units with AlternativePath or buildings with DynamicGridObstacle I often get a few “Penalty for some nodes has been reset while this modifier was active. Penalties might not be correctly set.” warning message from AlternativePath class. Sometimes this even leads to “Unhandled exception during pathfinding. Terminating.” in AstarPath class followed by a “Error : This part should never be reached.”

I’ve managed to lower the warnings by applying a 0.5 seconds delay for the Destroy command and disabling the AlternativePath or DynamicGridObstacle on the game objects when issuing this delayed destroy command. However I still receive some of these warnings :frowning:

Can you please let me know how to avoid this issue? I don’t know if the warnings causes any misbehavior, but when it gets to the error message the whole pathfinding collapses.

Thanks a lot for your help!

Sometimes it even gives an error message while it tries to display the warning message… Strange :confused:

I’m using the pro version of 3.8.6.

Hi

You get the warnings because when a dynamic grid obstacle recalculates a part of the grid graph, it will also recalculate the penalty and reset it to what it would have been if the graph had just been scanned. Since the AlternativePath modifier modifies the penalties of the nodes it becomes a bit confused when another script is also changing it at the same time. This will not break anything pathfinding wise however, but the effect of the alternative path modifier will be removed in the region where a graph update happens.

That it crashes the pathfinding system is a bug however. It seems I used the Debug.LogWarning(message, object) overload which cannot be used from a separate thread. To fix this, open AlternativePath.cs:108 and change it to use the Debug.LogWarning(message) overload.

You can prevent the DynamicGridObstacle component from modifying the penalties by changing it to instead of calling

 AstarPath.active.UpdateGraphs(bounds);

use

 var guo = new GraphUpdateObject(bounds);
 guo.resetPenaltyOnPhysics = false;
 AstarPath.active.UpdateGraphs(guo);

Hi, How can I turn off this warning, A* is installed in the Packages folder so I can’t make a modification. (I don’t want to move it to the Asset folder, it’s tiring to do the same process again every update)

if (warnPenalties) {
	Debug.LogWarning("Penalty for some nodes has been reset while the AlternativePath modifier was active (possibly because of a graph update). Some penalties might be incorrect (they may be lower than expected for the affected nodes)");
}

Thanks

@aron_granberg I know this is an old thread but I’m running through the same warning, I would just like to hide it from my logs, I understand why it’s throwing it and its effects are perfectly fine in my project, it’s just polluting the logs. Would really appreciate a way to not log this.

In fact if we could have a global option to control the verbosity of the A* pathing packages that would be great, for example for release builds I wouldn’t want anything below errors to be logged.