Loading Levels

In this page, you're going to learn how loading levels work and how to load your own level using a loading screen in the Menu.

Load A Level In The Menu

🔃 Loading Level With Loading Screen

Loading a level with a loading screen must be hard, right? For this, I made a simple function with many modification possibilities called "Load Level With Loading Screen" Call it to load a level.

The Load Level With Loading Screen Function
  • Level Name: Enter your level name here, including the .umap extension (e.g., MyLevel.umap).

  • World Context Object : Always Call Self And Connect It To This.

  • Loading Title : The title that would appear in loading screen

  • Loading Descreption : The descreption of the title of the loading screen

  • Random Images : If true the loading would use random images, if false you need to fill your image in the next input "Background Image"

To change these random images, search for an array called Loading Screen Random Images inside Settings_Configuration Data Asset

  • From Main Menu : Set this to true if you are loading a level from the main menu.

  • Restart ? : Set this to true if you are restarting an already loaded level .

⏬ How to update this level

Mostly Your game is going to have multiple levels and at some point your player is going to be on another level while progressing in the game, so how to tell the save game that level changed ?

When a player saves the game, the saved level is the one present in the Active Level Name variable within the GameLevelLoaded Component. This means that once you call Load Level With Loading Screenafter the player hits save game, the save will automatically have the newly loaded level as the default level.

How Does Level Load (Advanced)

🔃 Async Load / Unload Levels

Level loading is performed asynchronously. The LoadLevelAsync function is responsible for loading levels.

This is an example of how to use the LoadLevelAsync function inside your Game Mode.

//Required Header
#include "AsyncLevelLoading.h"

//Usage
AsyncLevelLoader->LoadLevelAsync(this, TEXT("exemple"), OnLoadCompletedDelegate);

AsyncLevelLoading Has Also functions to unload loaded levels

Unloading levels that haven't been loaded has no meaning and may be considered as retarded behaviour

//Dont forget to include the required header like in loadlevelasync exemple
AsyncLevelLoader->UnloadLevel(TEXT("exemple.umap"), this);

AsyncLevelLoading is a Blueprint library, meaning all functions are exposed as Blueprint nodes and can be called directly without C++ knowledge.

Load Level Async Node
Unload Level Node

👐 Open Loaded Level

After loading a level, you should open it, as loading a level without opening it has no meaning. Call the OpenLevelfunction to open your loaded level. Note that this function should only be called after the target level is loaded; you can do this by binding the OnLoadCompletedDelegateto this function.

UGameplayStatics::OpenLevel(WorldContextObject, LevelName.umapc);

Not that this function can be called using blueprints directly using Open Loaded Level Node :

Open Loaded Level Node

Last updated