help with setting up save game data variables

hi , I am somewhat new to unreal but I have a project going and in it I have a menu system from the marketplace that has a save game system in it. so I got it working (it already is set up to save player location and rotation in the level). it has a save game blueprint( bp_SaveGame) with an OnSaveGameSave and OnSaveGameLoad in it and I am told all I need to do is add variables in the save game blueprint and name them. it cant be that easy I figure though. I add an integer variable and name it ammo. does this mean it will save my current state of ammo? is there some other steps that need to be done? do I need to add nodes as well? I have some keys that open doors in a tunnel(destroy the actors(doors),if I grab 6 keys and open 3 doors and save the game , I am stuck in the tunnel between the first 3 doors and the next 3 doors, because it saves player location but not the keys I had and the first 3 doors respawn. I seen a lot of people showing adding variables to fill in the save data, but is there more than just adding the variables in the bp_savegame blueprint and naming them? is there additional steps involved like adding nodes in the blueprint as well? if I do name a variable does it need to be the exact name of what I am trying to save? etc…thanks for any help

Any help on this ? Thanks, also the keys would be destroyed actors when collected as I have no inventory.

The variables in the savegame blueprint should be references of the actual values. For ammo for example, you probably have it stored as a variable on the player controller. You need to reference this in the savegame blueprint and set it to the variable inside the blueprint on game save. One game load, you need to do the reference and GET the variable, then SET the reference on the player controller.

thanks I will look into this. for my keys I added a variable to bp_savegame like this. will it work this way? keys variable.png

or do they need to be individual? and can I just add the nodes into the sections shown in the pic in my character bp (save the game and restore save game state)?

Are the keys being stored as an array on your character? I can’t locate the variable that you are saving and referencing in the blueprint. All I can find is a reference to the character controller.

collected keys in the right panel must be marked as “SaveGame” or it will not be saved.

Well the character is from the third person shooter kit which originally had a different key system that teleported it on an AI death.i added a bp key blueprint and the color keys that are just picked up (actor destroyed at pickup) through an overlap box. There is an array variable in the character bp called “ owned keys”. I have to look again when i get home but i think now it references my color keys.though it is named a bit different than my variable. I m the ongamesaveload i tried to cast to TTP character but it said it cannot cast an array of objects or something like that. ——————————————————i did not know it had to be marked as savegame.Will look at that as well. Thanks

Can i sdd the same variable to my character bp? Will that help?

I didn’t realize that you had the ammo count attached to the player controller. If you do this, you may not need to reference a separate variable as it ‘should’ save the player controller in the state it’s in during save. When you reload this controller, the ammo count should persist with it as it was when it was saved.

key restore.png yea it will restore the default amount of ammo , say on a level change or after death. otherwise with my keys and this save variable thing , I don’t think I have a clue what i’m doing, this is really ugly ,LOL! Maybe I should look into that auto save plugin thingy I saw.(savior auto save plugin).

I noticed that under the original “OwnedKeys” variable array in the player character, if I put all my color keys in the default section. he already has the keys in play mode. no need to collect them.LOL!

anyone know why this setup will not save these two keys? restore key.png

someone said my save portion was correct but in restore save game I am setting the wrong variables, I am unsure how to set. also they tried to explain it this way but I don’t understand.

What you need to do: Code:

character.variable = savegame.variable
What you are doing: Code:

savegame.variable = savegame.variable