How to save the game properly?

I already read this:

But it explains pretty much nothing.

In my Game…

  • The Level Blueprint (To be precise everything thats not default)
  • Every Actor (Also Spawned at runtime ones)
  • PlayerState
  • PlayerCharacter+Content

needs to be saved.

Whats the point of the “SaveGame” Property Flag, If I can’t save references? Putting a Pawn Reference into the Savegame and trying to load it returns NULL.
It looks like I need to save every primitive data separately.

€dit: I know that serializing REFERENCES is pretty useless, but in Java for example, Objects can be serialized without saving each variable separately.
Deseralizing the Object simply restores the object.

The engine cannot know what variables you want to save and therefore you have to save each variable you need to be saved yourself. Saving the whole actor would mean saving tons of data that doesn’t need to be saved. A SaveGame file would very quickly be hundreds of megabytes big. Epic did well not allowing that kind of stuff.

You can’t make use of the SaveGame flag with blueprints only.

If you want to have a “snapshot” savegame instead of a cheap checkpoint savegame, you need everything.

A Switch I pressed should be pressed when I load the game. Doors I opened should be opened when I load the game.

Having to save everything by hand means I need a savegame structure for every class I create.

€dit: Think of an inventory. I pretty much need to save every single item by hand instead of putting the InventoryComponent into the SaveGame.

Nice examples. In both cases, saving one boolean variable for each instance is enough. 1 bit. Saving the whole actor would mean… well, I don’t know how much memory one actor takes but I’m sure it’s in the magnitude of megabytes or at least kilobytes.

This is the crunchpoint. What about Variables in the Level Blueprint? Each Level Blueprint is unique and thus I can’t access its members. How do i save that?
What about Actors I created after I created the SaveGame? I need to create a new Savegame Structure for this Actor.

This is in my eyes an absolutely inaccectable way of defining a “Save System”.

€dit: Theres also another problem: What about private members? They can’t be read.

Saving variables of the level blueprint is definitely going to be a bit messy. I never use the level blueprint, I don’t like the idea of binding logic to the level blueprint. There are a few things that are best to be implemented in the level blueprint but you’re most likely overusing it.

Save the transform aswell and spawn the actor when you load the game.

Saving is one of the things that definitely makes more fun in code. If you don’t want to implement it on yourself, there are a few saving plugins on the marketplace but those don’t have a magic button aswell.

This is why I made a plugin, to automatically save all the stuff I mark the “SaveGame” checkbox, including Level Blueprint’s logic…
Saving everything manually would’ve been a nightmare.

How do I start implementing a “Snapshot” Savegame System? In the end I need to save everything that differs from the initial state of the Level/Map.

It’s important to me that it works for the moment. Optimizations can be done later.

C++ shouldn’t be a hindrance, although the Game is currently BP heavy

There is no snapshot. End of story. I know it would be cool, but keep in mind a more complex UE4 game might easily take like 2GB of memory, sometimes even much more? Dump that to a snapshot and you have a 2GB savegame. 100 savegames = 200GB storage? No way Jose… yeah i know the textures and models wouldn’t need to be saved, but there just isn’t that kinda snapshot savegame. REALLY.

if you have like 40 bucks to invest then there is a good plugin that does a lot of work:

A free demo is available to check out the capabilities.

In the end it would be wise to just start. There’s nothing good unless you do it. Save your player health. level. Exp. Inventory. Ammunition. Solved puzzles. Completed dialogues. Destroyed actors. It depends a bit on your game. if you’re lazy then your savegame will be like Fallout 4 where one savegame is like 20MB. If you’re good and pack every boolean into one bit then maybe your savegame is like 5KB. be the savior who does not waste disk space like there is no tomorrow. Or go the easy way. Whatever you do - do something. Idle is the death.