Savegame class and inst

im using a savegame class where i keep my variables but in my gameinst im trying to set the variable fromthe savegame class to a number. does anyone why its not working?

How do you know it’s not working?

because when i start the game its at 0

That does not explain much. Here we see you set the value in the save object. How do you handle loading and saving?

As in ClockworkOcean’s 101:


like it does save and everything but the variable stays at 0 even tho i set it at 100 via the current stamina in the 3 pic

I mean, it’s your choice at this point. You either show how you do it and someone pokes holes in it, you fix it and move on or you’re stuck.

What’s in the image is OK. The issue is elsewhere, where we cannot see and can’t possible guess how you wired it up.

For all we know you could be creating a new empty save game object every time the game starts… rather than load existing data. Which does sound like it a bit.

You either don’t save the actual data later on which we can’t see or you have a problem with that variable, don’t ask my why but sometimes when creating var via ctrl+w (duplcate) it’s broken. Setting it doesn’t have any effect. Delete it, recompile, add again.

okay this is the whole script i use to save and load the game. Dont know what im doing wrong. but the game saves and loads as it should except that the value (stamina) starts at 0

like deleting the variable and adding it again? if thats the case it did not seem to work

You’re sort of on the right track, but you haven’t quite nailed it. It’s like this:

When you start, read the save game AND copy the value into the player ( I don’t think you did that part ).

When you save, copy value into the save game and write it.

1 Like

Hey, yeah i think i know what you mean. i have another question when working with save and load and i want to save a variable do i have to set the values manually or can i do it automatically.

i will try to solve to issue, i will be back in 1 hour or 2

Obviously, you have to set the variable in game, like always. You also have to copy those variables to the save game, to save them. Then, you have two ways of saving:

  1. Just write the save game to disk when you change something

  2. In a central place, like the game instance, set up something on begin play, that writes the save game on a timer. It could write it every few seconds, no problem.

Then, all you have to do is update the save game variable, because the writing is already taken care of :slight_smile:

1 Like

Yeah i fixed it thanks for the help as always mate, i appreciate it :slight_smile:

1 Like