How to Save & Load variables

The save system is set up so that it works from BP_CharacterBase, this makes it easier to save the inventory and other character related stats. All data gets sent to BP_Save, then when the character is spawned, it reads the data from there and sets the variables.

See how money is being saved as reference for saving and loading “normal” variables.

Weapons are saved automatically, you don’t need to make any changes to any Blueprint in order to save the weapons you made, just create a weapon, pick it up, save, done.

Enemies and other world objects do not get saved, as they aren’t part of the Character or its inventory.

In this tutorial we will save the players location and restore it when the player spawns, to begin, create a new variable (vector) inside BP_Save

save1

Then open BP_CharacterBase and open the SaveGame function and set the actors location to be the saved location vector we made in BP_Save

save2

Last, still in the character, on begin play, set the location to be the saved location and check the teleport checkbox

…and that’s it, the save system now has the player location too. You can repeat the entire process for rotation as well if you want.

Basically the idea is to send the data from BP_CharacterBase to BP_Save, then bring it back during loading.

TIP: when working with save data, it’s good to delete the save file after each change and start a new game, to avoid unexpected behavior.