A* Pathfinding Project

Scanning large Recast graph crashes computer


I am working on a game with a large amount of terrain. In certain areas, there are stairs leading up to a platform (like a deck or into a house). I have figured that a recast graph would be the best way to go.

I am able to get the graph to work over the whole terrain or work with small enough cell sizes to include the stairs in the scan but I cannot get them both to work at once. For instance, to get the stairs to be included in the navmesh, I need to make the cell size around 0.1, but any cell size under 0.5 (when the graph spans the whole terrain) gives me way too many voxels and will crash my computer.

So I am wondering, how can I create a navmesh for the whole terrain without increasing the cell size?

Could I just create multiple recast graphs? I have tried this and the AI agents wont cross between graphs. Is there a way to move the AI agent between graphs when they are at the edge?

Could I increase the tile size? I know this wont decrease the voxels but maybe less chunks will stop my computer from crashing? I’m not sure but I don’t like doing hard restarts so I’ll wait to see if anyone knows if this is less intensive than smaller tile sizes.



That’s odd. Does it give you any error message?

If you are using a tiled recast graph (make sure tiling is enabled) then it should only keep about tilesize*tilesize*threads voxel cells in memory at any time, regardless of how large the world is.
Could you post a screenshot of your settings?


Thanks for the fast reply. No error message is given, the display just cuts out if I have the cell size too small. I have tiles enabled and just tried with around 1024 and it still crashed.

These are the settings that I have been able to get working on the whole terrain but the cell size is still a bit too big for certain areas: https://imgur.com/a/5Hx8c4i


Did you check the editor log file after Unity crashed? (before you open unity again)


I don’t think it generated one. I checked in the project folder and in Unitys installation folder after trying it again. The whole computer shuts down so fast it’s making me think this might be a bad overclock on my CPU rather than ram usage. I’ll try with a lower clock then get back to you.


It doesn’t seem to have been a bad overclock, I tried on stock with no boost clock. Do you think limiting the thread count might stop it from crashing?



Well, it does sure seem like some kind of overheating issue or something.
You could try lowering the number of threads. Open the AstarParallel.cs file and change the ThreadCount.AutomaticHighLoad enum to something else.


Using less threads might have got it to work. It’s still scanning but it’s a lot further than it has been. It’s almost 1/3rd of the way done and has been running for a few hours on only 2 threads. It’s taking a while but that doesn’t bother me since it’s working.

It could be heat or maybe an uneven spot on the thermal paste but I don’t think it was (my CPU is water cooled and rarely goes above 60c in stress tests). It could be Unity not responding while using 100% of the CPU for long periods of time. Maybe the monitor just didn’t recognize the computer was still on and wouldn’t respond when attempting to move the mouse or use any keyboard commands. I’m not really sure, I’m just glad I can get it to work.


Thanks for the help. I have got it to work with 6 threads (as opposed to the 2 I was working with the other day) and it creates a nicely detailed graph.