Best practices - Streaming in a level

Hi All.

We have a plugin that we use that cuts up the scene into smaller chunks, and allows us to stream it on demand, based on the location of the player (so we constantly load/unload parts).

I wanted to get clear on the best way to handle this from the A* system’s perspective.

One approach will be to create the complete level graph before we split the scene, save it off and only load that at runtime.
I am a bit confused as to how to achieve this though, where does cache startup comes into play, do I need to save the graph and load it from code, where is scanning the graph comes into affect and so on.
If someone can give a step by step guide on how to get this done, that would be great.

Another approach will be to have graphs generated per scene files, however, since there are so many parts it seems like a very inefficient solution, but if I’m missing something, or anyone has some insight, I wanted to bring this up as well.

Is there a different approach I’ve missed?
Anyone has any insight/experience on dealing with this problem?

Hi

The first approach is the one I recommend.
During design time, you scan the graph and then save it to a file (or use the cached startup option), then in the game, you load the saved data and it will work just as if the whole level was present at same time.

Due to Unity’s new undo system, the editor becomes very slow when cached startup is used however, so I recommend that you save it to a file.

You can read all about how to do that here: http://arongranberg.com/astar/docs/save-load-graphs.php

In order to completely skip scanning the graphs at start, you will also want to uncheck A* Inspector -> Settings -> Scan on Awake.

Thanks Aron,

Can you elaborate on what exactly scan on awake does? is that the actual rebuilding of the graph, or does that populate some internal data that is needed?

Hi

Just rebuilding the graphs.
You don’t want this since you will be replacing the calculated data with the saved data.