Saving runtime variable changes via Blueprint

#Plugin

I could probably engineer a plugin for saving entirely in editor, no c++ required

But any ideas on how this would work?

what would you expect / want in terms of what you would supply to my Save game BP Node?

I can save arrays yes

would just be a series of arrays of each data type?

Rama

Rama @evernewjoy posted some explorations about C++ game data saving, which is great and I hope he releases a friendly explanation of that entire research.

I asked the devs during beta about a saving game tutorial and they said it’s on the horizon; I fear they have more pressing concerns for now.

For example, say you have a player text input for a character name and you want to store that, and use it from then on whenever the game is run (until the player changes it).

I’m interested to see if someone can offer a totally in editor method for a designer-oriented case where blueprint variables are all established in a single array of saveable vars/values, and it can be told to Restore (LoadGameState) and Update (Store New Value and SaveGameState) from any event you like. And it would be nice to also show how those stored variables can be called in various other blueprints, such as through comparisons.

I’ve seen some existing blueprint functions which handle something like that, but I don’t know how they work, and it would be great to declare and initialise variables to handle everything without having to go to VStudio.

Regards, and sorry if this question is already answered.

@tomofnz

I did a video showing a working method for this whole problem using UDK which is posted as a video on www.cgcircuit.com … bringing together various processes explained on the forums, all patched together until I got what I wanted to work. I was sort of hoping it would be easier with the new tools.

I’m not sure if this is the best description, but here goes.

There’s this program called Articy:Draft for branching stories which has a Global Variables list, and you just set the type, the name, the initial value and a description (or comment) about each entry. The entries can be grouped to keep the list readable, but that’s no big deal - they’re searchable - all within a single designer friendly table in the software (a bit like a Slate panel I guess).

You can then get those variables anywhere in the story tree, Package.Asset style, except it’s written as GroupName.VarName, and it even uses intellisense to help avoid typos. Really easy.

Okay. Next part is that in UDK it was, or is, possible to adjust the value of a variable declared in the MyPawn.uc class using the SuperModifyProperty kismet node (not part of UDK, an extra from the forums) because it permitted the editor to add the Player variable as the target. This worked because all the relevant vars were kept in the pawn class … though it allowed you to make any object serialised if you needed that, like a KActor for instance). Changing values worked during run-time with a bit of a push from an additional Kismet script to notify what channel to update. I can see that in Blueprint this would be kind of similar, but with C++ written nodes setting and getting the variables. I can’t do that part.

Then in UDK all that was needed was to use a JSon Serialize/Deserialize method that saves or loads the whole gamestate from two console commands. It’d take any changed values and write them to file on ‘SaveGame MySav’. And it would set the values for the variables to what was on the .sav file on ‘LoadGame MySav’. [I don’t care about encrypting it or anything flash].

The clunky part was having to do an entire gametype just to make use of the save/load functionality, but I guess that’s life. When working, in UDK, it is really fast and lightweight. I figure, with source code exposure, it could be packaged to be a very simple plugin tool, as you said. Then everyone wouldn’t need to do keep coming up with the same thing over again.

I suppose that it would be good to populate a list of public, saveable variables, but also be able to send a variable created within a blueprint to belong in that list too … of course, if an actual separate list itself is really needed at all.

Of course, elite coders would require more crazy tools for their specific cases, but I’m just after a baby steps version.

This is doable right now! You need to create a new Blueprint that derives from the SaveGame class. Add to it any variables you need for state (eg player health, inventory etc). When you want to save there is a function ‘create SaveGame from class’ which you use to create an instance of it, set the properties, then use ‘save game to slot’, giving a name to the save. When you want to load, you can load the save game by name, cast it to the particular save game BP you made, and access the state variables you added, passing them to the right places.

As mentioned above, we will do a tutorial on this at some point!

I posted a reply and a comment but they seem to be dissolving in the system… but yes. Save, Load, UpdateThis(send in a changed var value).

I look forward to that more than anything in the world right now. I’m giving it a try myself, inchworm style.

Can I use a Custom Event to send from other blueprints to the SaveGameBlueprint? I tried custom events earlier but they didn’t seem to work at all at the time or I was doing it wrong. I’ll try more.

In the image, I drew some question marks … if a Saving Vars tutorial is coming, it would be nice to know what to do with those marked parts.

As for the graph, is this layout necessary? For changed values, is it sufficient to change the ExampleInt value (default=0) to 1 then do another SaveGameToSlot after that?

Or this, better … but would it work, not sure how to check yet.

And this is how I understand to fire the OnSaveCommand custom event, but it doesn’t seem to work, so I’m stumped.

In the level blueprint (or wherever) I have an Input of Enter, and that gets from an Object variable the CustomSaveBlueprint class I made, and from that I can presumably fire off the OnSaveCommand (seems kind of like an Action>Activate Remote Event in UDK). Not getting any result in the log though - I have a PrintString that isn’t showing its string in the save blueprint.

Would really really really love to see that tutorial! I’m having trouble figuring out how saving with blueprints works and I have no idea how to figure out how it works So I’m just blundering around doing not much of anything.

I think it will much easier to explain with an example, I will try and put something together next week! Sorry for the confusion.

Is there any information about it in the documentation? I can’t seem to find anything.

bump :wink: - alright to do that?

Well, apparently TappyChicken has an example of all this inside of it, which is great, and from that I have what I need.
Might have been nice to know back in March. Still I’m pretty happy now.

This tutorial should make it clear and simple and no more confusion :slight_smile:

HI
I do it somewhat differently. I will prepare an example later because as you say, there’s some complicated parts.

For your video, thanks. In there about 06:30 you are talking about why not to use a String variable and I think the reason you didn’t get that to work is you need to set a default value for the String in its Details panel, then it works fine. It’s probably helpful it the stringname and the string value are the same but they don’t have to be. It just won’t accept None, the default.