High Cost of Initialization

We have some large outdoor scenes that utilize Recast Graphs. These can be ~5MB size according to the startup cache. The initialization cost (Awake function in AStarPath) can be quite high, especially on Xbox One. We are seeing times in the 8 or 9 second range.

Now this wouldn’t be that bad as a one-time cost, however due to the way our game is set up, we load outdoor and indoor scenes, each with A* objects. So every time a scene loads, the AStarPath for that scene is created fresh with Awake() getting called. Which means every time you go from indoors->outdoors there is an extra long load due to the AStarPath initialization.

What I have attempted to do is persist the A* object across loads (using DoNotDestroyOnLoad) and deactivating it, but this has resulted in runtime errors. I know the AStarPath is designed as a Singleton system, but I was hopeful I could maintain the integrity of that as long as only one AStarPath was active at a time.

Do you have any advice on how to allow for more than one AStarPath to exist at once, as long as only one is active?

Hi

You probably want to look into saving graphs to files.
See http://arongranberg.com/astar/docs/save-load-graphs.php