Best Practices for Large Maps?

Hi there, love the project, really good stuff!

So, I have to implement the recast graph for my game. The thing is; the play area can be quite large (up to 1600 x 1600 x 100 (height) units), and the surface of the map can change based on player modifying the height, adding elements, buildings etc. My agent radius is also set to 0.5. So if I follow the recommended specs, it gives me a warning saying that the map will be too slow.

Now, I’m planning on building (saving etc) the graph when the terrain has finished loading/generating, so it all happens during a load screen. This is fine. For updating it, I’ll use the “parts of graphs” as explained in the documentation.

But how should I setup the graph? Is it possible to split the graph into smaller chunks? Like instead of one massive graph, have 4~16 smaller ones? How would I link them?


I would recommend a recast graph as your are already using. The warning shows because it may indeed take some time to scan the graph, but for many games this is perfectly ok. I just don’t want people to think it has frozen Unity.
You should use tiling on your recast graph. This means that each tile can be recalculated separately, which is a lot faster than recalculating the whole graph).

1 Like

Alright, I’ll be doing that then!

For the recalculation, I’m manually creating a Bounds object based on the size of the chunk that was modified. Is that alright or does it need to be attached to a mesh? I was expecting that the graph would take that bounds object, figure out which tile to update, and update it. Is this correct?

However, I’m getting the following warning when trying to calculate the graph:

No MeshFilters were found contained in the layers specified by the ‘mask’ variables
Pathfinding.RecastGraph:CollectMeshes(Bounds) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:748)
Pathfinding.RecastGraph:Pathfinding.IUpdatableGraph.UpdateAreaInit(GraphUpdateObject) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:447)
Pathfinding.GraphUpdateProcessor:ProcessRegularUpdates(Boolean) (at Assets/AstarPathfindingProject/Core/Misc/GraphUpdateProcessor.cs:225)
Pathfinding.GraphUpdateProcessor:ProcessGraphUpdates(Boolean) (at Assets/AstarPathfindingProject/Core/Misc/GraphUpdateProcessor.cs:186)
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean) (at Assets/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:241)
AstarPath:PerformBlockingActions(Boolean) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:801)
AstarPath:Update() (at Assets/AstarPathfindingProject/Core/AstarPath.cs:785)”

However I’ve only set one layer as the mask (Terrain), and I do have objects in that layer in the scene. What else could be causing this issue?


Yes, just use a bounding box which encapsulates all changes.

That warning indicates that inside the bounding box which was updated, there were no objects (meshes/colliders/terrains/etc.) from which to calculate the graph.
Do you have any large completely empty regions in your world?