Announcement

Collapse
No announcement yet.

Save game overwrite only works once?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Save game overwrite only works once?

    It seems when I write to my save game file it works fine the first time and loads the data ok but when I exit and come back in and attempt to open the same save file it looks like it's loading and the file size is still the same but the static meshes are missing from the viewport. The world outliner still shows them in there but there's nothing in the view.

    This is my first time doing anything with save games so I'm not sure if I'm just not understanding something about their abilities or functions. Any help or advice would be appreciate. I know there's a lot in my blueprint and it would take a while to show everything in each variable so maybe even just pointing in the direction of which variable or piece of save data might be something to look at and do a print string on?

    #2
    Also I verified that it works fine once per slot. I can load a different puzzle which saves to a different slot and it will save and load fine once each time but after the first time loading correctly it will fail the second time.

    Comment


      #3
      Originally posted by 3Daoist View Post
      Also I verified that it works fine once per slot. I can load a different puzzle which saves to a different slot and it will save and load fine once each time but after the first time loading correctly it will fail the second time.
      You only supposed to create the save game once. You're creating it every time you save, so it will only work for the last time you did it.

      Once it's created, that's it, never do it again, just read and write

      Comment


        #4
        Originally posted by ClockworkOcean View Post

        You only supposed to create the save game once. You're creating it every time you save, so it will only work for the last time you did it.

        Once it's created, that's it, never do it again, just read and write
        Hmm... So I only use that create save once. Only once per session? Once per time opening the level? Oh wait... I think I have it... I've been using my save function both when the game starts but also every time the pieces get moved. So I need to update my save event to only save to the slot each time but not create the save game object except once per session?

        Comment


          #5
          Originally posted by 3Daoist View Post

          Hmm... So I only use that create save once. Only once per session? Once per time opening the level? Oh wait... I think I have it... I've been using my save function both when the game starts but also every time the pieces get moved. So I need to update my save event to only save to the slot each time but not create the save game object except once per session?
          You create the save game ONCE - EVER

          After that, you only write to it or read from it.

          What you actually read and write really depends on what you're trying to do.

          Tell me if you need more info.

          Comment


            #6
            Is there any way you could give me an example of how it would look blueprint-wise to set it up to create a save object and then update it later?

            Comment


              #7
              Oh and to give you more info if it helps I am making a jigsaw puzzle game and I am trying to set it up so that it saves when you open a puzzle and then updates the save each time a puzzle piece is dropped. Then if the player chooses the same puzzle again it will see that there is a savegame with the same slot name and load the puzzle in progress instead of generating a new one.

              Comment


                #8
                Originally posted by 3Daoist View Post
                Oh and to give you more info if it helps I am making a jigsaw puzzle game and I am trying to set it up so that it saves when you open a puzzle and then updates the save each time a puzzle piece is dropped. Then if the player chooses the same puzzle again it will see that there is a savegame with the same slot name and load the puzzle in progress instead of generating a new one.
                First time ever you say:

                Click image for larger version

Name:	make.JPG
Views:	92
Size:	64.7 KB
ID:	1768734

                Then, when something useful happens, you say something like:

                Click image for larger version

Name:	update.JPG
Views:	82
Size:	87.8 KB
ID:	1768735

                It doesn't really matter what I'm updating here, the main point is: load the save game, update it and write it back.

                When you want to get something from the save game:

                Click image for larger version

Name:	read.JPG
Views:	73
Size:	83.7 KB
ID:	1768736

                So, same process without the write back.

                Crucial points are:

                1) Only make it once. If you make it again, everthing previously save is gone.

                2) When you want to update it, read it, make the change and write it back.

                PS: It's good to quote, otherwise I don't get a notification:

                Click image for larger version

Name:	quote.JPG
Views:	68
Size:	8.0 KB
ID:	1768737

                Comment


                  #9
                  Originally posted by ClockworkOcean View Post

                  First time ever you say:

                  Click image for larger version

Name:	make.JPG
Views:	92
Size:	64.7 KB
ID:	1768734

                  Then, when something useful happens, you say something like:

                  Click image for larger version

Name:	update.JPG
Views:	82
Size:	87.8 KB
ID:	1768735

                  It doesn't really matter what I'm updating here, the main point is: load the save game, update it and write it back.

                  When you want to get something from the save game:

                  Click image for larger version

Name:	read.JPG
Views:	73
Size:	83.7 KB
ID:	1768736

                  So, same process without the write back.

                  Crucial points are:

                  1) Only make it once. If you make it again, everthing previously save is gone.

                  2) When you want to update it, read it, make the change and write it back.

                  PS: It's good to quote, otherwise I don't get a notification:

                  Click image for larger version

Name:	quote.JPG
Views:	68
Size:	8.0 KB
ID:	1768737
                  Thanks Ok I think this gives me a good starting point. I'll reference your blueprints and try to come up with something. I'll post again when I either have a solution or hit another wall. Appreciate your help.

                  Comment


                    #10
                    Originally posted by ClockworkOcean View Post

                    First time ever you say:

                    Click image for larger version

Name:	make.JPG
Views:	92
Size:	64.7 KB
ID:	1768734

                    Then, when something useful happens, you say something like:

                    Click image for larger version

Name:	update.JPG
Views:	82
Size:	87.8 KB
ID:	1768735

                    It doesn't really matter what I'm updating here, the main point is: load the save game, update it and write it back.

                    When you want to get something from the save game:

                    Click image for larger version

Name:	read.JPG
Views:	73
Size:	83.7 KB
ID:	1768736

                    So, same process without the write back.

                    Crucial points are:

                    1) Only make it once. If you make it again, everthing previously save is gone.

                    2) When you want to update it, read it, make the change and write it back.

                    PS: It's good to quote, otherwise I don't get a notification:

                    Click image for larger version

Name:	quote.JPG
Views:	68
Size:	8.0 KB
ID:	1768737
                    Ok so I am attempting to rearrange the scripts and I think I've made some progress on making it cleaner but at the moment it's not working. I'm going to try and trouble shoot it more on my own for a bit before posting my current version of the scripts but I do have some questions.

                    A) Would it be smart to create the savegameBP object in the game instance immediately on the game running (checking of course first if there already is one) so that it's loaded once right away and available to other blueprints when needed?
                    B) Does the check for savegame work when you don't put a slot name into it? When it just says default and has no incoming pin does it just check for ANY save games?

                    I can't think of anything else at the moment.

                    Comment


                      #11
                      Originally posted by 3Daoist View Post

                      Ok so I am attempting to rearrange the scripts and I think I've made some progress on making it cleaner but at the moment it's not working. I'm going to try and trouble shoot it more on my own for a bit before posting my current version of the scripts but I do have some questions.

                      A) Would it be smart to create the savegameBP object in the game instance immediately on the game running (checking of course first if there already is one) so that it's loaded once right away and available to other blueprints when needed?
                      B) Does the check for savegame work when you don't put a slot name into it? When it just says default and has no incoming pin does it just check for ANY save games?

                      I can't think of anything else at the moment.
                      1) You can put it on BeginPlay in the game instance. But you have to ask yourself, why have a reference to the save game in the game instance? It's just an extra step, and the save game is available everywhere just like the game instance.

                      2) No, you have to specify which slot you want to check.

                      Comment


                        #12
                        Originally posted by ClockworkOcean View Post

                        1) You can put it on BeginPlay in the game instance. But you have to ask yourself, why have a reference to the save game in the game instance? It's just an extra step, and the save game is available everywhere just like the game instance.

                        2) No, you have to specify which slot you want to check.
                        Awesome thanks again for all your help. I think I am getting closer to a solution. Now I can spawn a puzzle and have it save correctly and I can close and reopen indefinitely and it loads correctly each time. Just having issues with my savegame variable failing an isvalid check when trying to update the save data on puzzle piece dropping. Guess I need to load game from slot every time I want to update the data? Can't just update the savegameobject variable I created?

                        Comment


                          #13
                          Originally posted by 3Daoist View Post

                          Awesome thanks again for all your help. I think I am getting closer to a solution. Now I can spawn a puzzle and have it save correctly and I can close and reopen indefinitely and it loads correctly each time. Just having issues with my savegame variable failing an isvalid check when trying to update the save data on puzzle piece dropping. Guess I need to load game from slot every time I want to update the data? Can't just update the savegameobject variable I created?
                          You will 'come a croppa' if you update the variable. For many reason, for example, you have to also remember to write it back to the save game at some point. But also, if the game crashes, the player loses everything. Whereas if you are writing to the save game all the time, everything's always up to date.

                          Show me the code that's not casting properly...

                          Comment


                            #14
                            Originally posted by ClockworkOcean View Post

                            You will 'come a croppa' if you update the variable. For many reason, for example, you have to also remember to write it back to the save game at some point. But also, if the game crashes, the player loses everything. Whereas if you are writing to the save game all the time, everything's always up to date.

                            Show me the code that's not casting properly...
                            Ok here goes.

                            Starting with the master game mode blueprint. I've set up events to fire when called by other blueprints and those events fire the functions.
                            Click image for larger version

Name:	GameModeEvents.jpg
Views:	50
Size:	309.1 KB
ID:	1770212
                            On level load the puzzle spawner blueprint starts by firing the does save exist event. That fires off this function:
                            Click image for larger version

Name:	DoesSaveExistFunction.jpg
Views:	50
Size:	164.6 KB
ID:	1770213
                            If true it then loads the game. If false it runs that sequence.
                            The save blueprint seems to work the first time when firing off after the initial puzzle spawning but it's failing when I move a piece and it's supposed to fire off the save again because that savepuzzles variable fails to validate.
                            Here's the save blueprint now:
                            Click image for larger version

Name:	SaveFunction01.jpg
Views:	49
Size:	161.9 KB
ID:	1770214
                            Click image for larger version

Name:	SaveFunction02.jpg
Views:	47
Size:	128.9 KB
ID:	1770215
                            Click image for larger version

Name:	SaveFunction03.jpg
Views:	45
Size:	158.7 KB
ID:	1770216
                            Attached Files

                            Comment


                              #15
                              Originally posted by 3Daoist View Post

                              Ok here goes.

                              Starting with the master game mode blueprint. I've set up events to fire when called by other blueprints and those events fire the functions.
                              Click image for larger version  Name:	GameModeEvents.jpg Views:	0 Size:	309.1 KB ID:	1770212
                              On level load the puzzle spawner blueprint starts by firing the does save exist event. That fires off this function:
                              Click image for larger version  Name:	DoesSaveExistFunction.jpg Views:	0 Size:	164.6 KB ID:	1770213
                              If true it then loads the game. If false it runs that sequence.
                              The save blueprint seems to work the first time when firing off after the initial puzzle spawning but it's failing when I move a piece and it's supposed to fire off the save again because that savepuzzles variable fails to validate.
                              Here's the save blueprint now:
                              Click image for larger version  Name:	SaveFunction01.jpg Views:	0 Size:	161.9 KB ID:	1770214
                              Click image for larger version  Name:	SaveFunction02.jpg Views:	0 Size:	128.9 KB ID:	1770215
                              Click image for larger version  Name:	SaveFunction03.jpg Views:	0 Size:	158.7 KB ID:	1770216
                              Ok, if you're using the save game variable like that, of course it's fine. I meant don't just use it instead of the save game, only occaisionally write it back.

                              It looks pretty logical to me, what's the problem?

                              EDIT: Sorry ignore that question, I re-read your stuff...

                              EDIT2: I think it's because your load save game event doesn't set the save game variable?
                              Last edited by ClockworkOcean; 06-02-2020, 12:41 PM.

                              Comment

                              Working...
                              X