How to save variables using a User Structure?

The problem is within my picture and the associated text.

I’ll help you out. The problem is you are not copying the variables to the savevariables savegame actor.

Btw, the Make/Break structuresavegame are redundant, you can set those variables in the int nodes following them.

Thank you for looking at my problem. Could you try and explain how I can do that?

I’m assuming SaveVariable is your custom savegame class. You would have your structuresavegame added as a variable to it.

You need to spawn a SaveVariable in the beginning of the game (either in your character blueprint or HUD, depends on your preference) and set your SaveVariables to it.

Then all you have to do is get the SaveVariables value, cast it to a SaveVariable actor and set its structuresavegame values to whatever you want before doing the actual saving. You basically need to update the values of the SaveVariables actor before saving them on file otherwise it’ll keep saving the default values.

Thank you for pointing me in the right direction. I didn’t have to spawn a SaveVariables in Characteror HUD blueprints.

I have posted my solution below, but will most certainly mark your answer as correct. I appreciate your help.

#1: This is a blueprint with the parent class of BlueprintFunctionLibrary. I have three functions inside of this library.

Start New Game: It creates a SaveGameObject from the game class SaveVariables_C it can be found under #2. It then saves it and prints strings, and finally returns the blueprint found under #2 called SaveVariables.

Save the Game: Saves the SaveGame blueprint SaveVariables, found under #2, with whatever filename you want.

Load Game: Loads the filename you want and returns the SaveGame blueprint SaveVariables, found under #2.

#2: This is a blueprint with the parent class of SaveGame. Inside of here I have created a single variable in reference to a blueprint structure, StructureSaveGame, I have created containing all of the variables I want to save and load.

#3: This is the Level Blueprint. It first checks for a saved game and if true it will run the LoadGame function, found under #1, sets SaveVariables(look in the details panel to the left) and breaks the StructureSaveGame so I can use those values to set variables in my pawn class which I use for drawing the HUD. If it checks for a saved game and returns false it will run the function StartNewGame, found under #1, set SaveVariables and then draw the HUD.

#4: This is also in the Level Blueprint and is how I save values in the SaveGame object SaveVariables and the StructureSaveGame. It runs the function SavetheGame, found under #1.