Unreal Engine 4: Level Streaming Demystified

posted in HunterGaming for project Farkle Friends
Published December 12, 2018
Advertisement

So I have finally got some level streaming to work in the project I'm working on. The next blog might be progress on it. But for now I want to explain quickly how level streaming is designed to work and how to get it to work for streaming just a single level. I have a small level that is too small to be broken into smaller pieces but large enough to take few seconds to load it. Like a lot of things the official docs are good but doesn't help for situations like mine.

Level streaming is normally used to load and unload one level into another level. Making it easy to have large levels broken into pieces. You have just a small, whats referred to as a persistent level, to start and load other levels into and out of your persistent level as needed. So you set up a trigger so when the player walks through another part of the level is loaded. Is it a process that can be seen so you must take care to make sure the player can't see that level until its completely loaded.

You have the option to load the level asynchronously or not by checking Should Block on Load.

1.png.5b8cee68d747aa8d9a5e60fa5a3f91a1.png

In order to set up level streaming you must add the level you want to stream to a list of levels. The level that is currently open at this point will automatically be chosen as the persistent level.

2.png.13cae2641cb1bf17c42baafd0b074f52.png

The level that is currently loaded will automatically be selected as the persistent level. Once there you can click the Levels drop down menu to either create a new level, or load an already existing level, to add to the list. Levels added here will be the sub levels you want to load. For me right now its just one level called Downtown_L.

3.png.ced5811c1a7cc057ec3470698ebf308e.png

Now there is a lot of good tutorials and documentation available on the internet but they all explain it from a standpoint of having large levels broken into small levels and loading/unloading as needed. There is not much out there explaining from the standpoint of a single level that is too large to just load using OpenLevel because it takes too mush time to load and blocks the main thread until its done loading. Which I think is where a lot of one-man-band indie developers are coming from as being the only person working on a game limits,somewhat how large levels can be. Unless your willing to spend large amounts of time on it.

So how do you go about using this technology to load smaller single levels? Well what I did was create a completely empty level to use as the persistent level. So it loads super quickly. In begin play of that persistent level I show a loading screen. I should be able to eventually make the loading screen animated as level loading shouldn't be a blocking task now. After the loading screen is shown I immediately call LoadStreamLevel to load my single level into the empty level. Now it work. The empty level is loaded super quickly and shows the loading screen. Which currently is just text that says loading. But it stays there as the level is loaded and is removed once the level is finished loading. As its not blocking and I don't yet have a loading screen that blocks the whole screen, I can see the level being put together. It's kinda cool. I will be updating my loading screen next to make sure it blocks the whole screen and looks pretty to the player. Here is my begin play from the persistent level's level blueprint.

4.png.eb9ef8243e50b58139bc2ab3900022b6.png

5.png.4ead3fcee6d8f8bfd82de636d7f73d0e.png

6.png.9c253f933db2e4a09cbaa7ed8ffe438e.png

1 likes 4 comments

Comments

HunterGaming

Little update I just found out. It wasn't spawning the player because I didn't set the game mode overrides for the persistent level. However the player character still doesn't seem to be placed at the player start. I still have to move it to there.

December 13, 2018 02:42 AM
John Daniels

Great article HunterGaming,  just failed test with console because loading times with no animated loading screen.  Was thinking of using level streaming because it allows animated loading screens.  Maybe you could help with a few questions.   

Currently the game plays a movie and then boots to a main screen.  From the main screen there is a Play button which opens a widget that has 6 Maps/Levels to choose from.  When you click on the map it loads.

Do you think load times would even benefit from level streaming?  What I was thinking is everything could be loaded at the very beginning while the movie is playing, even if it took 40 seconds.  That way when the player chooses a map it will instantly pop up and it will also pass testing because there is a loading screen, the movie.

What is confusing is how all the levels load, in this game each level is different.  Will all the levels be in the same wold or level?

Thanks again for the great article,

John
Proud Arts LLC

 

As a side not game mode changes but maybe that could be worked around.

 

August 04, 2019 03:54 PM
HunterGaming

Sorry I was never notified about this comment for some reason. I think loading times are about the same between level streaming and not. If I remember right with level streaming you CAN have multiple levels in one level but only if you want to. I think you would add them to the level just like any other asset. Doing it this way only the level you load by calling "Load Stream Level" would be loaded.

December 21, 2019 12:27 PM
Big_R-07

Hey I was curious. Any idea on why (with my game mode set in the persistent level and spawning my character then possessing it) I can't move? Or why my character isn't being rendered?

January 22, 2020 05:09 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement