How do I use the SaveGame flag?
I already know how to save and load variables explicitly handled by a subclass of SaveGameObject as demonstrated in the TappyChicken examples. So, no problems there.
This question is about saving variables stored in multiple spawnable/placable Blueprint actors.
A basic scenario
Let's say we have a single-player adventure style game with lots of doors. Each door is an instance of some Blueprint that contains the mesh components and an event graph handling the behaviour. The player can open or close any door, and when quitting the game, the state of each door (open or closed) must be stored in the players savegame object so that the next time the player starts the game, all the doors will show up in the same state they were when he quit the previous game.
This is clearly not an unusual feature, but I can't figure out how it's supposed to be handled. Looking through the hidden part of the details panel for variables created in a Blueprint reveals a flag labeled "SaveGame" which, according to the tooltip, should toggle serialization for it in saved games:
It's probably safe to assume that this flag has something to do with the answer to my question, but it's unclear how to make use of it. When testing it out using the ordinary SaveGameObject routine, it doesn't appear to make any difference to the data stored in the .sav-file, so clearly I'm missing some crucial piece of information.
Since this kind of serialization potentially applies to hundreds of actors in any given level, it doesn't seem like a SaveGameObject is designed to handle it. If the player breaks a destructible, it should already be destroyed when the containing map is reloaded at a later time, and if he finds and steals a one-of-a-kind magic sausage with unicorn dust on it in level 5, then that magic sausage should most certainly not be available again the next time the same player enters level 5... Well, you get the idea by now.
asked May 11 '14 at 12:38 PM in Blueprint Scripting
I know this is an older post, but it still comes up in searches. The SaveGame is used by FArchive::Serialize() internally when ArIsSaveGame is set. Any variables on the blueprint that have SaveGame checked will be serialized. I've done all this in C++ where I call Serialize() in a C++ class that blueprints inherit from my C++ class and then the archiver will check for the SaveGame being checked on properties in the blueprints and will also serialize those out to disk as well.
I'm not sure if you can directly use SaveGame in a blueprint only save scheme.
See this documentation about SaveGame property: https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Properties/Specifiers/SaveGame/index.html
See this documentation for saving games in blueprint or C++: https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/index.html
For tips on using the archiver in C++ definitely see this post and read the Fortnite portion: https://answers.unrealengine.com/questions/35618/savingloading-an-array-of-objects.html?sort=oldest
Or to simplify it you can stick to using blueprints only :)
Here's a nice and simple example: https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/index.html
Implemented it into my own game and it works like a charm!
answered Feb 26 '15 at 07:54 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here