Hi Aron.
I’m loving your pathfinder and I have a question.
Using your alternative path modifier, how do I manually reset the penalties? I would like to be able to free up the nodes a unit has traveled (after it’s reached the destination) or if I need to alter the path slightly while moving along it.
Hi
You will need to open the AlternativePath.cs script and make the InversePrevious method public, then you can call it inside a safe update callback to reset the penalties. You probably also need to make the prevNodes field public and set that to null immediately after you call that method.
AstarPath.RegisterSafeUpdate(() => {
alternativePath.InversePrevious();
alternativePath.prevNodes = null;
}
Note that the AlternativePath modifier will clear the penalties every time the path is recalculated so you can also just issue a path request to clear it.
Also using RegisterSafeUpdate is not optimal for throughput since it needs to pause the pathfinding threads, but if you don’t have many agents it will be fine.
Thanks for the reply Aron.
It works beautifully now!! I will definitely buy the pro version to support you :).
1 Like