Happy Monday everyone!
Casey here today to talk about additive scene loading. Today’s post will be a bit longer than most, but that’s because of the high level of interest revolving around this topic and the complexity of the topic itself.
Additive scene loading in Unity is much like the layers feature in Photoshop. Usually in Unity, everything is contained within one scene, but with an additive scene structure, you can have many individual scenes for your level–even separate scenes for your menu, your character, and your lighting. To make your game, these separate scenes are all combined and layered on top of one another, instead of having to include everything in one scene.
Additive scenes are powerful tools mainly utilized in open world games to create a seamless experience without loading screens while a player is exploring a larger level. The benefits sound attractive, but for this structure to be done well, you need to put in a lot of planning and forethought. In addition, you will also need to communicate with your team how to test and continue to develop the game, for if you are changing the entire loading structure, it can become difficult to test.
Before you start your adventure into additive scene loading, you need to ask yourself some design questions:
- Is the idea of a seamless experience important to the core design?
- Is my team willing to learn how to work with this new structure?
- Is most of my development team’s code modular and only getting references by using Unity’s ‘GameObject.FindGameObjectWithTag’ method? (alternatively: is my team willing to change our code to do this)?
- What scene will be the active scene? / How will I trigger a level segment to begin to load/unload?
- What type of lighting are we using and where will the lighting data be stored?
- What is the processing power of the minimum required specs to play our game?
- Am I okay with small amounts of game stutter if I don’t heavily optimize the code and the scene?
If you said yes to everything, or have a plan on how to answer everything, then I recommend that you start playing around with the idea of additive scene loading. I’m not gonna teach you here, but if you want, I recommend you start by checking out this documentation:
Core to Additive Scenes: LoadSceneAsync
General Scene Managing: SceneManager
We just recently implemented additive scenes in Umbrella Mondays with moderate levels of success. It did add a bit of temporary confusion and slowed down our pipeline for a little bit while everyone acclimated, but the additive scenes made it so we have fewer merge conflicts because everyone can work in different scenes.
Overall our game’s scene flow structure is as follows:
*Note that the Build Index of splash should always be 0. Unity tries to load index 0 differently than other scene indexes because it assumes index 0 is the splash scene.
Now that I’ve sold you on how awesome this structure is, I’d like to provide a couple reasons why you maybe shouldn’t build your game this way. If you’re going to use this structure, you should know some of the difficulties that we’ve run into while working with it and understand that there is a large amount of learning and work needed to implement additive scene loading functionality.
Regarding Cross Scene References:
You cannot access game objects in other scenes. The work-around for this is using ‘gameObject.FindGameObjectByTag(‘Tag’). Alternatively, you can instantiate a copy of an object into another scene via the “MoveGameObjectToScene()” method found here. You could also purchase the Advanced Multi-Scene plugin (we don’t use this for Umbrella Mondays).
Regarding Loading and Optimization:
Unity’s “LoadLevelAsync()” command doesn’t load very well and can cause stuttering. Furthermore, loading times vary depending on hardware, thus making debugging load time issues difficult and sometimes random. We found that the debugging process went easiest when we BUILT our game and then ran it on a machine that could barely run it and saw what broke. Everything needs to be highly optimized in order for additive scenes to work. In addition, after additive scene loading is implemented, problems can be harder to solve using Unity’s Profiler.
It should also be noted that additive scenes are a new/underdeveloped feature in Unity, yet they’re quickly becoming the current industry standard (sort of). Some game companies currently work with Unity to modify and customize the Unity source code to make the loading work better. Thus, the high-end tools are still proprietary to the companies that created and use them, making this solution out of the reach of most small developers. Each loading scheme must be tailored and highly optimized for each project, and some optimization can only be done by higher-end studios due to the need to access Unity source code to get better a loading structure.
In summary, choosing to incorporate additive scene loading can have a very large impact on the project, as it affects how the game performs, runs, and fundamentally functions. Adding this loading functionality requires a lot of work, care, and forethought to make it work at an acceptable level, and can cause lots of strange issues (such as objects being duplicated into scenes, or scenes thinking a change has happened upon loading when nothing has changed).
If you’re willing to tackle the challenges, additive scene loading gives a professional feel to a game, but oftentimes isn’t necessary and might wind up being more trouble than it’s worth. Consider the needs of your project, as well as your own interests and ability to tackle all of the problems that may arise.
That being said, I’d like to share some useful videos I found that aid in the concepting and implementation of these ideas and structures, if you’re interested in learning more!
Playdead’s talk about stutter-free 60 FPS in their game ‘Inside.’ https://youtu.be/mQ2KTRn4BMI
Unity Live Training – Additive Level Loading: https://www.youtube.com/watch?v=Drb61_C8-SQ
Multi-Scene editing in a professional setting; great ideas for how to set up your editor for your team: https://www.youtube.com/watch?v=KRmqy22z0SM
Best of luck!
We’re releasing Umbrella Mondays in EXACTLY ONE WEEK! (Well, six days and nineteen hours, but who’s counting?). Come check us out at Stout Game Expo (SGX) on April 30th, from 6-9pm in the Memorial Student Center Great Hall at UW-Stout!