Setting Save Game Variables Works Only After SGO Was Written To Disc?

Hi!
I am struggling to understand what is happening in my project right now and hope to find some help here.

I created a save system for my first person game, and I tried to keep it modular and sclable.
However, I notices after deleting all the save profiles written to disk (to check if the game saves fine), that certain variables from my save game object are not immediately changed when they are called during gameplay.
{Please note, the setup for the upgrades is just for testing}

For instance: I created the save system inside the first person template from unreal. I edited the weapon pickup to change a variable in the struct “Player Upgrades”, and then save the game via an interface call.

Now, if I load up my autosave file, the gun will be added automatically to the player, because the player blueprint asks:

This works fine. But only if the save file “Autosave” already exists in the SaveGames location:

The blue true is from the weapon pickup and comes after I set the struct within the weapon pickup to true.
The yellow true comes from the game instance, where I just get the struct, split it and print the bool.

However,
This is confusing me, because if I delete the save file and then play again, the gun gets not saved and the save game object seemingly is not edited:

The weapon pickup bool says true, but inside my game instance its now false. Thus, the struct is not getting changed, but why? Is it a timing problem? But how can that be if the save game data command comes after I edited the struct?

I really want to fix that because for now, I ask inside the Game Instance if a Autosave exist and if not, just write to disk. But it seems weird to me that the struct isnt getting changed if the save game was not written to disk, even though I create a save game object in the beginning.

The Init Event is called via Event Init-

Sorry if this seems confusing, I hope I communicated my issue in somewhat clear way!

Small Add:
This whole issue bothers me because I collect the gun, autosave, and then save manually for a profile 01 for example. But if “Profile 01” isnt existing already in the directory, the gun bool isnt saved.
Only if Profile 01 exists, and then I save, the gun bool is getting saved correctly.

Hey @Cronoss95

I believe your problem is handling save game’s in two different places and forgetting to update something along the way or not passing the relevant data (save game object?) to the other “side”.
My suggestion would be to centralize all your save/load logic (in game instance or dedicated “Save Manager”) and go from there.

Hope that helps.

Hi hello! Thanks for the reply, I was able to figure it out by now: I already have my saving and loading inside my game instance, but accidentally was creating two different save game objects - and the one that gets overwritten by the actors in the level was never saved, just the second one that was created again during the saving in my GI.

But thanks for the reply! :slight_smile:

1 Like