Approach For Large Worlds With Many Agents

I’m dealing with some large worlds, talking potentially thousands by thousands of nodes wide–well beyond the scope of a single grid graph. A single large recast graph does actually do the trick for baseline pathfinding but the game itself is well suited to a grid graph logically (everything is placed on a strict grid) for modifiers/costs.

This is a large top down RTS like world in terms of pathfinding needs.

It does seem like the suggestion you’ve given in the docs and elsewhere is to use a single large recast graph. But everything in the game is placed on a strict grid and modifications to move speed etc. for agents maps well in that manner.

I know this can be accomplished with the recast graph–and have done so on smaller scales in the past–but I just want to do due diligence and make sure that multiple grid graphs would work.

Basically here’s the setup:

  • Large, fully procedural, map (25+ 1000 meter square terrain tiles)
  • Small grid size (2m per tile. Approximately 2500 grid cells per terrain tile)
  • Individual cells on map can modify pathfinding behavior. Faster pathways, blocked paths, etc. are all being positioned cell by cell
  • Approximately 200 pathfinding agents at once across the entire map is the realistic worse case scenario.

Bonus follow up question: In a world this large with nodes potentially this small, even a Recast graph takes a moment to generate–would multiple recast graphs be better (maybe 1 per 1km tile)?

ProceduralGraphMover to the rescue :smiley: From what you’re describing it looks like this may be your best bet, but I also recommend skimming through the Graph Updates During Runtime page in general.

EDIT: Specifically for having many agents, you’d want to make agents share this moving graph or graphs instead of having them all with their own graph or something. Maybe groups are assigned to graphs or the such- the implementation will differ by use case here quite a bit.

ProceduralGraphMover is cool for sure! The agents could be spread across the entire surface of the terrain though which is why I’ve not thought it really matched this use case but I’ll give it a closer look, thanks!

With some grouping and maybe even changing graph parameters on the fly you might be able to get something pretty decent. If you run into any issues, let us know :slight_smile: