I want to go over some fundamental ideas regarding level design before we get into the actual details of making levels in Unreal Engine 5. We won’t get too deep into subjects like level design; instead, we’ll focus on the primary distinction between main/persistent levels and sub-levels.
Main levels are the levels, where the whole world in your game changes. For example; this section in Call Of Duty Modern Warfare 2 (2011) that takes place in Brazil was named as “The Hornet’s Nest”.
Call Of Duty MW II (2011) — ” The Hornet’s Nest” Level
And this level was named as “Cliffhanger”.
Call Of Duty MW II (2011) — “Cliffhanger” Level
Even though these two levels might be recycling some assets, their design and scales are completely different, in addition to small gameplay differences that call for distinctness in design. But these two major (overall design and the scale) elements are what differentiates a main/persistent element from a sub-level.
Let’s talk about sub-levels. Let’s think of that “Cliffhanger” level, where stealth is kind of a star of the act in Modern Warfare 2. In this first part of the game, we see that the playable character has poor visibility, therefore we do not need to load every single area and asset in that level immediately, which would give us to optimize our levels better. Another reason why we might like to have sub-levels in this main level is that, rendering fog is heavy on hardware. There are things that can be done to optimize it, but if you can optimize anything even just a little bit further, it is worth it. If this explanation doesn’t make everything clear, don’t worry. I’ll make an another post where I’ll be demonstrating how level streaming can be used in favor of optimization.
In other words, by making sub-levels, we can basically figure out where our character is and, based on that location, we can load or unload the resources in our game environment. We can see persistent/main levels as these are the levels in which all of our sub-levels could be loaded into. A persistent level doesn’t necessarily need to have a sub-level, but it might. In UE5 “Persistent level” will be always the active level, even if we unload all of our sub-levels.
Note: Depending on the genre and how the level is designed, a game can have only one giant persistent map and many many other sub levels. The concept I’ve explained here applies more to linear games rather than open world games and it just represents a general idea. It is not very rare to find persistent levels with no sub-levels.
Your advertisement can be placed here for $200 permanently. Suggested resolutions: 1800x663 or 1400x1400. Contact us.
What I am about to advise is my personal preference. Using this method was very helpful for me to keep everything in my “Content Browser” organized.
To get started with the levels, well, we need multiple levels that we can load/unload or in other terms stream/pause them.
To add a new level to our game, we can click on File > New level and select a desired level from that menu. To save a level, we can press Ctrl + S. Although you can save your level in any folder, it’s a common principle to create one called Levels/Maps to keep things organized.
Saving the two levels I created.
To execute such task, all we need to do is navigating to the folder where our levels are saved in. In my case, it would be All > Content > FirstPerson > Maps.
If we double click on any of these levels, Unreal will load that level for us.
Of course people who will be playing our game won’t have access to the “Content Browser” menu, so we need to create an event listener that triggers, when our playable character collides with something or someone, then we can unload the previous level and load the new level.
To keep everything organized, I’ll navigate back to my “Blueprints” folder and create an actor here. If you’re not familiar what actors are, you can read this post here. To create the actor, we can right click on an empty space and then > “Blueprints Class” > “Actor”.
Created an actor that will help me loading my second level.
Now all I need to is to double click on this actor, and attach a collision object to it so I can check if my character is colliding with it. This next step is not necessary, but I’ll be attaching a static mesh (Plane, in this case.) so my character can walk on it, but as I said, it is not necessary.
Adding a plane (Static Mesh) so the character can walk on it.
Attaching a box collision to the plane so I can check whether this mesh collides with my character or not, and if so, I can trigger an event. Be mindful of adjusting the scale of your collision box. If it is too small, and does not collide with your character, the event listener will not trigger.
Now the next step is creating the trigger itself. Compile the asset first, then scroll down on the right side of the screen until you see the event listener called “On Component Begin Overlap”. (Make sure your collision element is selected. Otherwise you won’t be able to see the following menu.)
As we can see here in this screenshot, we can also use other event listeners to execute some other actions, such as unloading our level.
Clicking the plus (+) icon there will lead us to the “Event Graph” editor.
We have two options to open our level. Open Level (by Name) and Open Level (by Object Reference). I’ll be showing how to use both methods.
When opening a level with “Open Level (by Name)” executable action, pay attention to typing your level name correctly. This box here is upper/lowercase sensitive.
Compile, save it and do not forget to place your actor in your map and go test it! We do not need to create the plane to have the collusion by the way. Do not forget to go to File > Save all to save the changes you’ve made!
If you prefer “Open Level (by Object Reference)” all you need to is bringing that executable to the event graph and selecting the level you want your character to go to. And that’s it.
Window > Levels path reveals the sub levels in our level.
Creating a sub-level in the “Levels” windows.
A very important note about default UE5 templates: As you might already saw in the tutorial, I am using the default FPS template that comes with UE5. And this template does not come with any “registered” levels. What it means is, if you try to display the sub-levels in this default template by going to “Window > Levels”, you’ll encounter the error of “This feature is disabled when world partition is enabled.” whether this option is enabled or not in the first place. This is the engine’s default behaviour. To avoid this issue and problems that it could create in the future, I suggest always starting with a clean level by creating a new level by using the method of “File > New Level”.
This tutorial has already become quite lengthy, so I’ve decided to create a detailed guide on implementing level streaming in UE5 here.
Note: If you are tired of watching video tutorials and would like to see more text-based tutorials like this one from me, you can support me on Patreon so I can dedicate more time to creating them.