Download

[Plugin] Auto-Save Game


[Now available on Unreal Marketplace]

https://cdn1.epicgames.com/ue/item/Store_Savior_Thumb-284x246-ec959fe7a61e1054a455b6d79578fc2d.png

-Excuse me sir, do you have a moment to talk about our lord and savior?* :wink:


Hey community; I have something here under my belt for a while and was wondering if you would have any interest on it.
I’m a bit lazy for certain boring tasks I don’t like… Such as managing variables for save game files, pulling them in and out, configuring everything manually in Blueprint Graphs, etc.
So, to avoid boredom when managing data for my future game projects I’ve decided to dive a little into this matter and create an automated Save/Load game system, avoiding the solutions out there stating ‘ease of use’ but then require a lot of manual labor just to save a bunch of variables and load them back into the game. That is when this little guy was born, I call it Savior!

So, please let me explain to you how automated he is…
To use the SaveGame system provided by Epic, we must create a Blueprint of type SaveGame, populate that Blueprint with ‘mirror variables’ for each of our games’ important classes, create Blueprint functions to save each of our classes to the disk, and when loading pull them back into the characters, items, enemies, etc and etc…
When you create another property for your character, you must open the SaveGame Blueprint and add a mirror variable to the list again and re-work the loading of the character, again;
And when we change something again, we have to do that again… And again, and…
Kind of unnecessary labour if you ask me. Recently someone released a tool to shrink all that process of creating SaveGame files into a single node, but every time we use that custom node, for each variable we must use another node, and another… And another, and…; Also, the tool ignores the fact that .SAV files are locked down while you are writing data to it.
When the game has a complex character, that ‘single node’ becomes a lot of nodes as well, also becomes unproductive.
With that in mind, I’ve proposed to myself: “-let’s truly automate this thingy 'cause I don’t wanna ever waste time with this again”.
And at this point, thanks to a little key guidance from an Epic Games’ engineer, here’s what I propose to you for adding Savior to your projects:

http://i.imgur.com/IPEih8m.png

http://i.imgur.com/yJ0jOnO.png

How automated is that? :slight_smile:
Best thing is, it’s still a .sav file which supports saving and loading your game on any of the platforms already supported by UE4.
Let me show you a little of the overall process of how you save/load whole game world’s objects, with position and rotation automatically handled for you, and how you save your Blueprint Graphs’ variables:

First - You create two custom Blueprints provided by the Plugin, one is the automation system and the other is just an custom Actor. They come with these option fields:

http://i.imgur.com/XbFszwo.png

http://i.imgur.com/usLKOnQ.png

You can add or remove Slot spaces, as many as you wish to provide your players and give them whatever name you like;
Using the ‘Actor Scope’ filter you can leave ‘Actor’ class as default or you can customize it to save only the types of Blueprints you need, like in the image above.
Then you add the ‘Saver Actor’ to your game level and you’re done with configuration. Your game level will be saved based on the options from the Saver Actor; That simple:

http://i.imgur.com/k9rUgCA.png

After having the Actor and Blueprint options the way you desire, every object in your level of the classes you assigned to the Scope will have their position, size and rotation automatically saved for you into the SaveGame, you don’t need to do anything about it.
So, how to save variables from graphs? Let’s see, I’ve created in my Character Blueprint these variables:

http://i.imgur.com/aGfJ7FQ.png

I want to save to the disk the variables HP, *MP *and SP; so I **select each of them and at the ‘Show Advanced’ dropdown, check for it the ‘SaveGame’ flag:
**And that’s it, Savior will save and load the variable for you, no need to create mirror variables or assign/read values using Blueprint nodes! :slight_smile:

http://i.imgur.com/LBwRYkR.png

Then whenever I reopen the game with ‘Auto Load’ enabled, everything is at the values that the game just saved, with ***zero C++ or Blueprint programming required:


http://i.imgur.com/leda71O.png

Still, if you want to have control over everything and don’t like the idea of something auto saving/loading important game data without your supervision…
You can disable Auto-Load and Auto-Save, controlling all the process yourself and still keep usage of the SaveGame tags, there’s plenty of nodes for you to do that:

http://i.imgur.com/6b9ZWIk.png

http://i.imgur.com/OkTDLKN.png

If you like it, please let me know; Cheers!


Demo .EXE:
DOWNLOAD DEMO HERE](https://mega.nz/#!D5EiiIoD!mpoqiGWPDKI7YvpjBnAcUNcOGbJMBKfroOydV-12fQU)

Latest Demo Project:
https://www.dropbox.com/s/h46212iehbvu2oa/Savior_1.5.6_DemoProject.zip?dl=0

Quick Setup Guide Video:

https://www.youtube.com/watch?v=7EkeqjsrkJA


Known Limitations:

  • ‘User Defined Structs’, Blueprint Structs, are not Auto-Saved due to their level of complexity.
  • Actors created at runtime must be re-spawned with same unique names before you call LoadGame().

FAQs:

° Which Engine versions are supported?

  • I will keep Plugin updated and compatible with current UE4 major release.

° Which types can I use with the Auto-Save system?

  • Close to anything supported by the default SaveGame system.
  • Bools, ints, floats, vectors, transforms, enums, structs? Check ‘SaveGame’ box and done.
  • Custom Blueprint Enum, Blueprint Array? Check ‘SaveGame’ box and done.
  • Blueprint Structs aren’t there, unfortunately; But your custom C++ Structs are supported.

° Which platforms are supported?

  • Anywhere supported by UE4.

° How do I install Plugin?

  • Plugins require C++ Compiler to work; You need Visual Studio or XCode Installed.
  • For Blueprint-Only projects, convert to C++ project first.
  • If you use file from Gumroad, copy the ‘Plugins’ folder from zip into your project’s folder. Restart editor.

° How do I setup the Actor/Blueprint for Auto-Save?

° How do I Save/Load manually from Blueprint Graphs?

  • The Plugin provides custom Functions, Blueprint Nodes and Events;

º How do I Save/Load manually from C++ code?

  • Grab a pointer to the Saver Actor in World. Then simply call Saver->SaveGame(); or Saver->LoadGame();

° How do I save all Actors in Scene?

  • Open your Savior Blueprint and, in the ‘Class Defaults’ panel, drop-down the Actor Scope list and click the “+” to add new item.
  • If it’s not in the list yet, add the class ‘Actor’; Compile and Save.

° How do I save the Level Blueprint?

  • On Saver Actor’s details, check ‘Save Level Blueprint’ box.

° How do I save Game Mode and Game State?

  • On Saver Actor details, check ‘Save Game Mode’ box.

° How do I save only my Character Blueprint?

  • A Player’s Character is part of the Game Mode logic; To save, check the ‘Save Game Mode’ box.

° How do I save runtime generated Actors?

  • When spawning Actors in runtime, make sure they spawn having always the same, unique, name.
  • They also must be spawned before you load or the system will ignore those Actors.
  • If an Actor is saved with name “Enemy1” and next time is spawned named “Enemy2”, the system considers him a potential memory violation and won’t load his data.

° How do I overwrite old saved file while in development?

  • Uncheck Auto-Load, in Saver Actor, check Auto-Save. All old data will be replaced.
  • Or delete the .sav files from the SaveGame folder.

° How do I setup multiple Slot files?

  • Open the ‘Class Defaults’ panel of your Savior Blueprint; At the ‘Slots’ list, click the “+” to add another Slot.
  • From the ‘Class Defaults’ panel or from your UMG widget’s graph, set Savior.SlotID = 1;
  • Make sure the Slot’s name isn’t empty, type a name for it; Now game will save to Slot 1 instead of Slot 0.
  • This is useful for RPGs and other progression based games where your players can have multiple save files.

° Why some Actors are saving, but aren’t loading?

  • You have changed its name, changed its parent class or there’s another Actor in scene with same name.
  • In this case the saved data is deprecated and you need to save again, overwriting old file.
  • Keep in mind that, if you want an Actor properly loaded, it’s name must be unique; Not the Label, the real object’s name.

° How do I Auto-Save my Graph’s Arrays?

  • Blueprint Arrays are supported by Auto-Save system, they can now be dynamic sized as well.
  • Simply tag it with the ‘SaveGame’ flag just like any other variable types in your Graph.

° How do I Auto-Save my own Structs?

  • If you’re not C++ programmer, your BP Graphs’ Structs must be of types ‘FSaviorStruct’ for Auto-Save to consider them.
  • If you’re programmer, you can easily overload FArchive’s operator in your code to add your custom Structs for Auto-Save support.

º How to Package my Project in Debug-Mode with Plugin included?

  • To link the Plugin to your Debug build, you must add its name to the ‘PublicDependencyModuleNames’ field in ‘PROJECTNAME.Build.cs’ before packaging.

º How to Package my Project in Shipping-Mode with Plugin included?

  • To link the Plugin to your Final build, you must add its name to the ‘PrivateDependencyModuleNames’ field in ‘PROJECTNAME.Build.cs’ before packaging;
  • If you’re having issues, try in the Project Settings panel(Edit->Project Settings…) checking the ‘Full Rebuild’ option before packaging.

º How is Multiplayer profiles saved?

  • Only the server saves ‘.sav’ files locally for each Player; On Load, replicated Actors should update just fine after Server have the changes applied.

º How do I load a Slot using the ‘Open Level’ node?

  • Demo project has a detailed example built on Blueprints of how to use ‘Open Level’ the “Epic Way” to load a game or start a new one.

º What are the license terms?

  • Your license is perpetual and you can use the plugin for as many seats you need and for as many projects you make.
  • I just ask you kindly please do not share source code or runtime libraries with pirates.
  • You can read more about UE4 Marketplace’s terms here: https://publish.unrealengine.com/faq

UPDATES:

1.5.5 (UE4.14+):
Marketplace Status: Updated
Gumroad Status: Updated

º Mobile Platforms binaries are now included, so your mobile blueprint game can use this plugin now without having to have Visual Studio installed to build C++ code.

º Fixed issue preventing non-root mesh/skeletal components to save their transform information; now they save transform even if set as sub-components.

º Added an option to try automatically respawn procedural Actors before loading the game world.
For this to work, your ‘Procedural Actor’ must contain a “+Proc” Actor Tag (NOT Component Tag).
This makes easier than ever for you to add to your Game, Actors generated at runtime, they will be restored to the Level from the .sav file.
If the Procedural Actor is member of a Streaming Level, Savior will try to re-assign that Streamed Level as owner of the respawned Actor for you, if possible.
Keep in mind that this system increases loading time!

[1.4.7] (UE4.12 & UE4.13):

º Added ‘Save/Load Game for Player’ functions to load from Slot ID to specific Player ID. Mainly useful for local multiplayer games.
This works like the ‘Save/Load Game Mode’ functions (it affects only GameMode classes for the given Player ID, does nothing to the Level).

º Added ‘Load Game from File’ and ‘Save Game to File’ functions; With these you can type in the Slot’s name directly instead of ID.
Like ‘Save/Load to Slot’ functions, this works like original Save/Load nodes (will try to save or load the Level with everything in it).

[1.4.6] (UE4.12 & UE4.13):

[Fixed]: Linear Velocity of saved Actors weren’t properly restoring physics velocity; fixed.

[Added]:
º ‘Angular Velocity’ is now also auto-saved for Actors by default.
º Implemented Tag System.

[Tag System]:

http://i.imgur.com/SAHGFT0.jpg

º This version introduces a Tag system which can be used to quickly perform customized Save/Load operations without programming involved.
Sometimes you want to save the whole Game World automatically using the Actor Scope, but still control specific behaviour of specific Actors.
For example:
You have multiple instances of the same Blueprint spawned in the Level; for design reasons you suddenly decides some of them
should behave differently when the Game is saved or loaded, but in some cases there’s no way to identify by Name which Actor it is;
To identify which Actor it is, that you need the ‘SerializeWorld()’ function to process, some tedious programming effort would be required.

º To avoid a whole chunk of some serious C++ code or filling your Blueprints with unnecessary variables + spaghetti… Use Tags instead!
Here are the current Tags that you can add to your Actors or Components to customize the serialization system quickly for any Actor:

[1.4.5] (UE4.12 & UE4.13):

[Added]:

º Streamed Levels auto Save/Load support. (pre 1.4.5 sav files not supported)
º Streamed Levels’ Actors auto-destroy support. (pre 1.4.5 sav files not supported)
º ‘SerializeWorld()’ will now consider Streamed Level’s Actors properly.

[Fixed]:

º ‘DeserializePlayerPawn()’ wasn’t checking for Character Class; Fixed.
º ‘Prioritize()’ reworked; Fixed some conflicts against Streamed Level loading.

[Limitation]:
º Auto-Load Streams will NOT work correctly if you manually load more instances of the SAME Streamed Level already loaded.
If you absolutely need multiple Level copies, consider finding a way to set unique names for your manually loaded Maps.
Or just make sure that none of Actors from ‘Map A’ match unique Actor names from ‘Map B’.
However, it is expected to work flawlessly with World Composition tool though.

[1.4.4] (UE4.12 & UE4.13):

º Added option to auto-save Properties from GameInstance Blueprint.
º Fixed some critical performance bugs, thanks to James Steininger’s reports.
º Reworked ‘Save With Screenshot’ node, now more flexible to use and much more performant.
º Added option to ignore Player Pawn’s location when loading only Game Mode.
º ‘Save in Editor’ will now save to a private dedicated ‘.sav’ file.
º ‘Save Game Mode’ now saves to a dedicated ‘.sav’ file.

[1.4.3] (UE4.12):

º Added capability to save or load a Game World from .sav files in Editor without the Game running.
More info in THIS POST.

[1.4.2] (UE4.12):

[Added]:

º ‘Save Game Mode’ Blueprint Function: Saves Game progress without saving the whole Game Level.
This is very useful for saving or load complex Player data within any World Map at any time, like in Open World Games.
Note: It’s absolutely possible for you to save the whole World, and use this to load only the GameMode from the .sav file;
Note: It’s absolutely possible for you to save only the Game Mode, and load the game with default LoadGame() function.
The difference in ‘Load (by) Game Mode’ function is: You can load GameMode from any Slot saved from any other World(Level) Map that isn’t part of current World.

[Fixed]:

º ‘Auto-Load’ with ‘Save-Component’ checked could cause editor crash; fixed.

º A ‘Component Scope’ filter have been added to the Savior Blueprint, to increase safety when Saving/Loading Components.
Also Components must now be properly registered, else it will not be serialized.
Any Component that is a child of ‘UPrimitiveComponent’, mesh components, cannot be serialized from the .sav file (crash).

º General Performance optimizations.

[1.4.1] (UE4.12):

º Fixed bugs with the ‘Auto-Destroy’ Blueprint node.
º Added convenience function ‘Find Saver’ to make easier for Blueprints to save the game from anywhere.

http://i.imgur.com/5dTlylm.jpg

[1.4.0] (UE4.12):

º Ignored Actors list have been added to the saving Actor; any actors from the level directly added to this list will not be saved.
º Save / Load Isolated. Save or load any Actor to a separate .sav file, without saving the whole game Map.
º Isolated saved files support optional filename encryption. Useful for saving sensible data locally.
º New function to save Game with a Screenshot has been added; As well as a ‘Load Slot Screenshot’ function.

[1.3.5] (UE4.12):

º Editor Module have been added for improved general in-editor usage for developers.
º The ‘Savior Blueprint’, can now be created from Asset Browser’s popup menu; from there, the workflow you already know remains the same.
º A Settings tab have been added to ‘Edit -> Project Settings -> Synaptech -> Savior Settings’.
º From the new Settings tab, you can now configure various minor details for your general plugin usage, without the need to edit or recompile C++ files.
º Demo Project have been updated to 4.12.5 to fix incompatibilities it had with latest engine release.

The Settings tab and new Asset Browser menu will be specially useful for me, I plan to release more plugins related to the current ones released and having them
grouped under a distinct sub-menu will help me organize better the way plugins interact with each other in near future. Cheers.

New Settings Tab:

http://i.imgur.com/eKs5aHi.jpg

Is very simple to get default plugin settings from anywhere in your game, just use the blueprint node ‘Get Savior Settings’:

http://i.imgur.com/PTXPboB.jpg

Create Actor or Template blueprints from Asset Browser’s popup menu (right mouse button click):

http://i.imgur.com/66CB8sG.jpg

[1.3.2] (UE4.12):

º Characters Capsule Component now restores its rotation by default.
º Minor bug fix in LoadGameFromSlot(); Was firing wrong OnXXBegin Event.
º Minor bug fix in LoadGame(); OnLoadBegin Event was called twice.
º Minor bug fix in SaveGame(); OnSaveBegin Event was called twice.
º Added Custom ‘Does Save File Exist’ Blueprint Node which checks if file exist with Savior’s Slot ID + Player Postfix.
º Reworked ‘Savior Struct’ which supports serialization to .sav files automatically (alternative to ‘User Struct Blueprint’), you can now setup values as Arrays.

Note: Pre 1.3 ‘.sav’ files maybe may be incompatible for loading from 1.3.2.

[1.3] (UE4.12):

º Removed unnecessary serialization loops based on Controller IDs.
º Player’s Pawn/Character classes are properly saved, Pawns class was ignored before.
º Added support to Actor Components, now properly saved with owner Blueprint. ‘SaveGame’ tag on Components’ Properties are required as well.
º Added support to Custom C++ Components, now properly saved within owner Blueprint. ‘SaveGame’ tag on Components’ Properties are required as well.
º Added support to auto-save Components’ locations.

Known Issues:
º Static Mesh Components are not serializable from .sav files.
º UObjects (pure) are not supported by the SaveGame tag archiver. Consider using UActorComponents instead which are supported.

[1.2]:

**º Saver Actor .H made public by default, as requested by C++ programmers.
**- You can reference ASaver and its property easier and faster now, as well as having direct access to Saver->Savior blueprint.

**º All Actors now remembers when Destroyed.
**- If you want to destroy an Actor and keep it destroyed when Level loads from Disk, now all you have to do is to destroy the Actor using this new Node.

@BarisT can you confirm one last thing, please;

I imagine you don’t see in your Output Log panel these messages when you’re loading a level in your game?!
When loading a game and Debug checkbox in Saver actor is turned on, your BP_Key blueprints should fire logs like this…

I’m home today so I put together a little relaxed video going from level 1 up to level 3… modifying properties, streaming levels, spawning actors;
Then saving and loading them from file :slight_smile: