Hey there,
Working on TD game, there is a functionality that Player can sell multiple towers at a time. Those multiple towers could be selected freely so I can’t merge them as a larger bound. I need to create separated GUOs then update graph with those objects, simply my code looks like;
foreach(var tower in sellList) {
...
GraphUpdateObject guo = new GraphUpdateObject(guoBounds);
guo.addPenalty = -1000000;
guo.resetPenaltyOnPhysics = false;
guo.requiresFloodFill = false;
pathFinder.UpdateGraphs(guo);
}
I also subscribed AstarPath.OnGraphsUpdated callback in various classes which calculate new path for creeps, so calling “pathFinder.UpdateGraphs(guo);” in a loop is lame, as you expected at some point Astar will try to recalculate a new path before complete early request, thus I’m getting ;
“Canceled path because a new one was requested …”
I wonder if there is a way to put those GUO objects in a queue then call UpdateGraph, so far I didn’t find anything on documentation.
At this point I can add a function into AstarPath.UpdateGraphs(List<GraphUpdateObject>)
and call that function after loop, this should solve the problem, Actually this question is going to @aron_granberg directly does it make sense to you ?
My other Question is also related to “Canceled path because a new one was requested” error. Whenever player adds a new Tower I’m going to update graph and those my own PathFinder classes start to compute a new path for creeps if Player adds a new tower again while calculating new path I’m getting that error as usual. At that point I don’t need to old Path which is obsolete I don’t wanna wait to complete old path result and send new Path request, what is the proper way to cancel Path request ?
Thanks for your time