Save/Load Variable information from files

Is there a way to Save/Load Variable information with blueprint in files like .txt or csv?

The Blueprints have a Save System.

You can create a Blueprint of “Savegame” Parent Class. There you can create the Variables you want to save.

Later in the Blueprint where you want to call the Savesystem, you use the node “Create Savegame” and choose your class you created. Now you can get the variables which you created earlier from the return node and set them with the information you want to save. Then you take the “Save Game to Slot” node and plug in the return value from the Create Savegame into it. You also need to choose a SlotName (Savegame Filename). Later you can get the savegame back with “Load Game from Slot”. You just put in the same SlotName and cast the return of that node to your Savegame Class. Then you can get the variables and use them to set your original variables.

I’m pretty tired right now. If you can’t get this to work, i will show you an example tomorrow.

Meanwhile you could search youtube for a blueprint Savesystem. I know there is a tutorial. Only in case you don’t understand something. (:

Wow, you are the best :smiley:

Question: How would I go about if I have to save an unknown amount of variables, say the position of every movable object in the level where the player can add more objects to the level.

As long as this Object shares the same Base/Parent Class, you can make an array for the variable you want to save. And Vektor3 Array for example.

Then you use the “Get all Actors of Class” node to get the Actors you meant and go through the returning array with a for each loop. Now get the position from every element and fill the array with the ADD Node for Arrays.

Ok, Thanks. I am also asking about “unknown” amount of variables because I have made an Inventory system which saves different objects (of same parent class) in one array. And I would like to make it usable for multiplayer which means having to save these arrays for every player, and there is a unknown number of players? Any idea how this can be done? Thanks :slight_smile:

I don’t know if this system would be a good thing for Serverside Saves of an Inventory. I made an inventory a few months ago and i ran into the problem, that i didn’t know how to tell which inventory i stored.

For this you would need a unique ID, like the Steam ID for example. And if the server isn’t a listen server, you would need a completely extern server with a database savesystem.

But let’s say you only want a listenserver to be able to save the inventory of every player. You would still need to identify the player. So you would need a unique ID. Even if you save the inventory client side, you would need an ID for the server to remember that the inventory belongs to it.

I gave up on that, because i couldn’t find a good solution for it.

How ever you could make a Struct that contains the Array for the Items and the user ID. You can make an array of that struct to save multiple users and their ID. The number is not limited as long as you have an array that starts storing them.

You would need to check if the player is already saved (get the Savegame back, look through the struct array and check the ID, and give him the inventory back, or create a new entry into the struct array for him). This is the basic logic behind it, but i can’t help you here if it goes too deep into sessions/ID etc.

When it comes to saving object positions, this might be helpful. This video shows you an easy way to keep up with object location and saves and loads it as well. Also starts new game too.

Let me know if it was helpful at all. Thanks.