top of page

How To Save And Load A Game In Unreal Engine

Updated: Aug 25, 2023

In this beginner-friendly tutorial, we will walk you through all the steps and process of setting up a simple save and load system in Unreal Engine using Blueprints. By the end of this guide, you'll be able to save and load player data inside the level.


However, this guide only shows how to save and load the position of the player inside the level. For storing further data of the player, you will simply assign the values you want to save to the “Save Game to Slot” node.


 

saving and loading unreal engine 5

Table Of Contents




Creating A Save Game Blueprint

  • First launch Unreal Engine and go to the content browser.

  • Then Right Click in the content browser and select Blueprint class.

  • A window will appear in-front of you. Just search for the save game blueprint in the search bar and select it like this.

creating a save game blueprint

Create Variables and Starting Nodes


Nodes to be used:

  1. Does Save game exist node

  2. Branch node

Steps:

  • After making the Save game blueprint double click on it and create a Transform variable in the blueprint event graph.

  • Name it “player Pos” then compile and save it.

  • First to establish both functions, we will use the “Does Save game exist?” node and connect it to Event Begin Play. Type in the slot name with anything such as ‘save1’. This slot name will be used for every save or load function that will used in the future.

  • Then we will connect it to a “Branch node” which is basically a true or false node. This will determine whether the condition of the “Does Save game exist?” node is true or not.

Creating A Save Game Blueprint

  • Now, we will call the save logic when the condition of Branch node is false and the logic of load data will trigger when the condition of the Branch node is true.


Setting Up A Load Game Function


Nodes to be used:

  1. Load Game from Slot node

  2. Cast to BP Save node

  3. Get player position node

  4. Set Actor Transform node.

Steps:

  • First, we will setup the load game function. For that, take a “Load Game from Slot” node and plug it into the true end of the branch node. Make sure to put the slot name as ‘save1’ or anything you want to name the save file as.

  • After that use its return value to connect it to a “Cast to BP Save” node and promote its return value to a variable. Then plug both these nodes into a “Set Actor Transform” node.

Setting Up A Load Game Function

  • Now take a “Get player position” node and connect it with both “Cast to BP Save” node and “Set Actor Transform” node. This will get the saved position and rotation of the player from the save file and set it to the current position of the player.

Setting Up A Load Game Function

Setting Up A Save Game function


Nodes to be used:

  1. Create Save Game Object node

  2. Set player Pos node

  3. Save Game to Slot node

  4. Get Actor Transform node

  5. Set BP Save node

Steps:

  • To save the data of player we will use “Create Save Game Object” node and connect it to the false end of the branch. Then set its game class to the Save BP that we created earlier.


Setting Up A Save Game function

  • Then we take the “Set player Pos” node and connect it to the “Create Save Game Object” node as well as the “Save Game to Slot” node. This will save the current position and rotation of the player to the ‘save1’ slot.


Setting Up A Save Game function

  • Next step is to create a “Set BP Save” node and connect its return value to the “Create Save Game Object” return value.

Setting Up A Save Game function

  • Make sure the “Get Actor Transform” node is plugged into the “Set player Pos” node.

  • That’s it for the saving game part.

Calling The Save and Load Functions

  • Now, the next step is setting up the keys that will use these functions to save or load the game.

  • For this we will first use the “Does Save game exist?” node and Branch node and connect them to the Node of the key you made. You can search for the desired node of the key like this.


Setting Up A Save Game function

Setting Up A Save Game function

  • Then we will make a “Get BP save” node as well as “Set player Pos” node. The purpose of this is to use it to save the player position by connecting it to “Save Game to Slot” node.

Setting Up A Save Game function

  • The next step is loading the game which is very simple and straightforward. To do this, use the same 2 nodes of “Does Save game exist?” and “Branch node and connect it to the new key node you made.

  • The only difference here is that we will take a “Get BP save” node and use it to set the position of the player that was saved inside the save game slot.


Setting Up A Save Game function

  • That’s it for the loading game part.

Conclusion


Congratulations! You've successfully created a beginner-friendly save and load system in Unreal Engine using Blueprint scripting. Now you need to test your save and load system by triggering the save and load events in different situations and check if the saved data (player’s location) is correctly loaded when the game starts or when the player loads a saved game.


Disclaimer:

Make sure each node with a slot name has the identical name as the save file you intend to use for saving and loading. Any mistake in this part can mess up the save and load system.


To get notified of upcoming posts on Unreal Engine, I invite you to subscribe to our newsletter:




And if you are just getting started learning Unreal Engine, have a look at the Unreal Engine for Beginners Course :

373 views0 comments

Commentaires


bottom of page