Suggestions to prevent massive framerate drops during pathfinding

Users who are viewing this thread


So, the single biggest issue I have with the game has been the severe performance drops during very large battles, or specially sieges. And from what I can tell, the trigger seems to be any time when all/a lot of troops need to recalculate their pathfinding. In sieges this is particularly noticeable when a new and "better" path opens up, like the gate being knocked down, or a siege tower reaches the wall.

I have no clue how the programming part for the pathfinding works, and if it cannot be directly optimized, but maybe these few "tricks" could help a little:
  1. Stagger the processing of new pathfinding: Simply make the updating new massive pathfinding changes be more staggered out over time. Like, troops closest to a new path react to it first and recalculate their paths, then slowly expand outwards to other troops. Would be realistic too since it would take time for information to traverse the battlefield. So you could easily make it take several seconds for the outer-most troops to "learn" about the new path. How to implement it technically I dont know. Maybe make the various breaches trigger a lockdown of all troops recalculation of new paths and slowly enable them in a staggered fashion.
  2. Batch calculate new paths for grouped troops: If a number of troops are in close proximity to each other, why not make them recalculate a new path only once? Should be possible to make it so any recalculation of a new path makes a max of X friendly troops(of same grouping) within Y meters just follow the same path. That should greatly reduce the required calculations. This would again be realistic and possible make the AI more believable, since it would make troops seemingly work together in small groups.
  3. Cleaning up pathing in castles: Obviously there is something not quite right with the pathing in many castles. Having troops climb down from the walls by the ladders/siege towers because they prefer going in the newly broken down main gate is a bit silly. But many castles also have very complex and windy paths. While that is visually very pleasing and realistic, maybe a few short cuts could be added for invading troops to simply make pathing easier.
Just a few ideas I had during gameplay. Again, dont know if it is possible to implement in engine, but thought I would share nonetheless.
Top Bottom