Language:
Page Info
Engine Version:

Saving Your Game with Blueprints

Choose your OS:

Create a SaveGame Object

To create a new SaveGame object, create a new Blueprint Class . When the Pick Parent Class dialog pops up, expand the Custom Classes dropdown, then select SaveGame. You can use the search box to jump directly to SaveGame. Name your new blueprint MySaveGame.

savegame.png

In your new SaveGame object Blueprint, create variables for any information you would like to save.

In this example, there are also variables declared that will be used to store default values for the SaveSlotName and the UserIndex, so that each class that saves to this SaveGame object will not have to independently set those variables. This step is optional, and will cause there to be one save slot that gets overwritten if the default values are not changed.

SaveGameVariables.png

You can set default values for the variables after the Blueprint is compiled.

Saving a Variable

This is a snapshot of the entire saving setup. You can click the image to enlarge it.

First, create an instance, or copy, of your SaveGame object, using the Create Save Game Object node. Make sure you set the Save Game Class dropdown to the name of your new Blueprint, in this case, MySaveGame. The Create Save Game Object node will automatically change its output pin type to match the type you specify with the Save Game Class input, enabling you to use it directly, without a Cast To node. Save the resulting object to a variable by using Promote to Variable so that you can reuse the MySaveGame object you just created later on.

SaveGameBP_1.png

Now that you have a copy of your custom SaveGame object, MySaveGame, saved to the Save Game Instance variable, you can send information to it. Here, the Player Name is being set to "PlayerOne". You would repeat this step for any other variables you wanted to store information in.

SaveGameBP_2.png

Now, you can use the Save Game To Slot node to save the SaveGame object's information to the hard drive. The Save Game To Slot node takes in a file name and a user ID, which in this case, are the default values created earlier.

SaveGameBP_3.png

Loading a Variable

This is a snapshot of the entire saving setup. You can click the image to enlarge it.

This first step is optional, and is based on saving a default save slot and user ID within the SaveGame object. Here, an empty SaveGame object is first created, so the default SaveSlotName and UserIndex can be read from it. Again, this may not apply in all game implementations.

LoadGameBP_1.png

You can use the Load Game From Slot node to create an instance of your SaveGame object Blueprint. A Cast To node will be needed to treat the resulting object as a MySaveGame, which you will want to do so that you can store it in a variable for easy access later.

LoadGameBP_2.png

Once the new SaveGame object has been loaded from the hard drive, the variable values can be read from it and assigned to the necessary Actors or classes, or used directly as shown here.

LoadGameBP_3.png