Announcement

Collapse
No announcement yet.

[BLUEPRINTS] Need Help Saving & Loading Variables (Such as Current Ammo, Health, Hunger, etc.)

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

    [BLUEPRINTS] Need Help Saving & Loading Variables (Such as Current Ammo, Health, Hunger, etc.)

    Hi,

    I have been working on a saving and loading system and got one to work fully. However, it only saves the player location and actor location (such as cubes, spheres, etc.). I need it to also save player variables such as current ammo, health, hunger, etc. Here is the current setup in blueprints:


    Save Game:
    Click image for larger version

Name:	SaveGame.PNG
Views:	1
Size:	124.8 KB
ID:	1182954


    Load Game:
    Click image for larger version

Name:	LoadGame1.PNG
Views:	1
Size:	150.7 KB
ID:	1182955

    Click image for larger version

Name:	LoadGame2.PNG
Views:	1
Size:	106.2 KB
ID:	1182956

    If anyone would be able to help that would be great!

    Thanks,
    Thrillride Games

    #2
    Similar thread going on over here:

    https://forums.unrealengine.com/show...ng-And-Loading

    Looks like you know how to do everything, you just need to do the same thing with your other information. Add the variables you need to save to your save BP and set them like you are setting the locations above. Is there something specific that's keeping you from doing that?
    Gooner44
    Cribbage Sample Project on MP

    Comment


      #3
      Originally posted by Gooner44 View Post
      Similar thread going on over here:

      https://forums.unrealengine.com/show...ng-And-Loading

      Looks like you know how to do everything, you just need to do the same thing with your other information. Add the variables you need to save to your save BP and set them like you are setting the locations above. Is there something specific that's keeping you from doing that?
      Hi Gooner44,

      I have already set my variables in the save BP. The problem is that I'm not sure where to set my variables in the save and load system. It seems like the way the location is set is completely different from just doing normal variables. Would you be able to throw something together real quick and provide a screenshot for me? Or just explain where I would need to set the variables and tell me where the return values would go.

      Thanks!

      Comment


        #4
        Originally posted by Thrillride Games View Post
        I have already set my variables in the save BP. The problem is that I'm not sure where to set my variables in the save and load system. It seems like the way the location is set is completely different from just doing normal variables.
        It's not really. It's just a more advanced use-case- the method for saving/loading the value doesn't change, only you're already doing what you need to with that information. If you need to store, for example, the player's health in a save then create a variable for player health in the savegame, and store that variable in the savegame when saving, and get that variable from the savegame when loading. Then, say you have a material that changes based on the player's remaining health, you'd have to give it the correct health value. In a similar way, when you load an actor transform you may as well go ahead and update it's transform in the world.

        The save game object acts as a sort of protocol for loading/saving specific data. You have to go add the variables you want to save/load in the SaveGame Blueprint, but then everytime you save, you must pass in values (in a way) and everytime you load you'll have to do stuff with the data. What data and when you save/load are up to you, the designer.

        The tools and workflow for the 'protocol' are always the same- regardless of variable type.

        To prep a variable for saving, get a valid save game object (of your type), and drag the reference pin out and release for the context menu. Type "Set <VarName>", and select the correct option from that menu. Connect it along the execution line, and set the variable to the value you want to save, and once you've done that for each value you want to save, call Save Game To Slot for the savegame you've been using, and make sure the slot is unique to that save's purpose (If you have multiple players, you don't want Player 1 and Player 2 to overwrite each other's saves).

        To load a variable from disk, get a valid save game object, drag the reference out- This time type "Get <VarName>"- and the variable you'll be using for the rest of runtime should be set to the value you get from the get node. Do this for every value you want to load.


        Sorry if I came of too patronizing, I just wanted to break it down very simply.
        They broke the signatures so I removed mine thinking it'd be awhile. The signatures work again, but I haven't redone my signature yet.

        Comment


          #5
          Originally posted by KorkuVeren View Post
          It's not really. It's just a more advanced use-case- the method for saving/loading the value doesn't change, only you're already doing what you need to with that information. If you need to store, for example, the player's health in a save then create a variable for player health in the savegame, and store that variable in the savegame when saving, and get that variable from the savegame when loading. Then, say you have a material that changes based on the player's remaining health, you'd have to give it the correct health value. In a similar way, when you load an actor transform you may as well go ahead and update it's transform in the world.

          The save game object acts as a sort of protocol for loading/saving specific data. You have to go add the variables you want to save/load in the SaveGame Blueprint, but then everytime you save, you must pass in values (in a way) and everytime you load you'll have to do stuff with the data. What data and when you save/load are up to you, the designer.

          The tools and workflow for the 'protocol' are always the same- regardless of variable type.

          To prep a variable for saving, get a valid save game object (of your type), and drag the reference pin out and release for the context menu. Type "Set <VarName>", and select the correct option from that menu. Connect it along the execution line, and set the variable to the value you want to save, and once you've done that for each value you want to save, call Save Game To Slot for the savegame you've been using, and make sure the slot is unique to that save's purpose (If you have multiple players, you don't want Player 1 and Player 2 to overwrite each other's saves).

          To load a variable from disk, get a valid save game object, drag the reference out- This time type "Get <VarName>"- and the variable you'll be using for the rest of runtime should be set to the value you get from the get node. Do this for every value you want to load.


          Sorry if I came of too patronizing, I just wanted to break it down very simply.
          Hello KorkuVeren,

          i thought I understood fully what you were saying but, when I did everything you said, it didn't work. Here is what I have now:

          New Save Game:
          Click image for larger version

Name:	Save.PNG
Views:	1
Size:	153.4 KB
ID:	1107208

          New Load Game:
          Click image for larger version

Name:	Load.PNG
Views:	1
Size:	143.7 KB
ID:	1107209

          Comment


            #6
            Originally posted by Thrillride Games View Post
            New Load Game:
            [ATTACH=CONFIG]95007[/ATTACH]
            Are you testing the Hunger variable at all? Try printing the value to screen and/or saving it to a variable. In this case, right click anywhere and type "Set Hunger" and it should bring up your Hunger variable used in the first screenshot. You'll need to connect the SaveGame's Hunger to the Set Hunger node.

            Click image for larger version

Name:	c9c10ceaf50b7f9b10220b92cf9dfae0.png
Views:	1
Size:	39.8 KB
ID:	1107210
            They broke the signatures so I removed mine thinking it'd be awhile. The signatures work again, but I haven't redone my signature yet.

            Comment


              #7
              Originally posted by KorkuVeren View Post
              Are you testing the Hunger variable at all? Try printing the value to screen and/or saving it to a variable. In this case, right click anywhere and type "Set Hunger" and it should bring up your Hunger variable used in the first screenshot. You'll need to connect the SaveGame's Hunger to the Set Hunger node.

              [ATTACH=CONFIG]95008[/ATTACH]
              Thank you for providing the screenshot. It was very helpful. As well as the deep explanation. I was able to successfully save all my data such as hunger, health, ammo, etc. Thank you for your continuous help! Have a nice day

              Comment

              Working...
              X