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.
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.
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.
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.
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.