Save Game not working

Could someone pls help me figure out why my game dosent save.
The print string is firing. But when i close and reopen my game
the variables havent been saved.

Hi, Thank you for the reply. Ive zoomed in and created better pictures.
Here is the zoomed in game instance. On event init wich as i unerstand it runs as soon as the game is created, i make
sure there is a save slot, if not i create one.Im using the same file name and index as the game only needs one save slot.
So one is only created the first time the game is started. Ive checked that the file is there and it is. And there is only one file
'so i dont think the problem is that the game is reading from the wrong slot.

https://forums.unrealengine.com/filedata/fetch?filedataid=131542&type=thumb

The SaveGame event is called when exiting the widget where the player customizes their avatar. It looks like this:

https://forums.unrealengine.com/filedata/fetch?filedataid=131544&type=thumb

This is where the variables are loaded in from game instance to the PlayerCharacter pawn (Its a pawn as it will not be moved around in the level)
I have checked the loading process by printing out some variable values from the save fileto make sure the problem isnt in loading them. But they
are reset nothing has been saved.

https://forums.unrealengine.com/filedata/fetch?filedataid=131543&type=thumb

The chagnes the player makes to the character are remain until the game is turned off.
I think i am doing what you are recommending doing on point 1 and 2. Im a beginner at UE th,
this is the first time im working with save game. Am doing what you are describing or have
i missed something?

i don’t fully understand the problem but i got this when i moved my save game object and it started loading none and saving none but when i move it back to where i first created it, it started working again i dont know if you still having the problem though

I think you have to understand the way Save Game works. If it is loading None, then this means that there is no actual save file.

What that means is that you must create a save file for it to load, because otherwise it is trying to find something that doesn’t exist.

Normally you should make a function in your blueprint called “GetSaveGame”. It should have the input of a save slot, and the output of the save game reference.

  • In your “GetSaveGame” function, you first need to check if a save game exists with the “DoesSaveGameExist” node. Plug the return into a branch.
  • If it does exist, then load the game from the slot, cast it to your own save game class, and return it.
  • If it does not exist, then create a new save game object “CreateSaveGameObject” with your class, and return that.
  • Remember that you still must save to slot after modifying the save game object.
  • Finally, you need to have a save slot name, which you should store in a variable. I realize that your problem may simply be caused by trying to load a save game from a blank slot, which returns none. Use a slot name like “mysaveslot”.

Essentially, this function will try to see if a save game exists. If it does, then it will load that and return it. If it does not, then it will create a new save game.

1 Like