I plan to save the level format separately and was wondering what would be a good format for saving it. It will just be saving the piece names and the transforms for the most part, with no static meshes saved in it. What would be a good format to save them in that is free?
I had originally planned to use JSON, but found it is limited in blueprint without a paid plugin. Would the built in save game functions be good for this or is there some better options that I am missing? Eventually I might also use this system to create an in-game level editor.
Your question is not about json. json is a representation type of strings and plugins will modify its shape. So, it is nothing to do with your question, serialization and saves.
Your question should be like this.
How can I serialize and de-serialize whole level at once ?
You can’t do it with blueprints.
You need to touch C++
You need to store every static mesh names, actor transforms, their variables and etc and you need to re-spawn them with your loading.
As I know RAMA developed a plugin but I don’t know if it can save whole level at once.
I have my own plugin and it can serialize all variables in actor class, get and set variables by name. But again, it doesn’t have a feature like “save everything all at once”
But if you already have a serialization method, you can use pretty much everything.
If you want to save some basic variables like object’s positions, some strings and etc. you can use Unreal’s save system. there are bunch of tutorials for it. But you need to recursively get all your actor and write your own “Load Logic”
My question was about how to save a set of Data eray_ozr, which you clearly didn’t read. JSON was one possible option for saving the data since it will be a very limited amount of data. I am not asking how to load the level, which I know I will build myself in Blueprint. The data that I am saving will be something like:
I was only asking about possible save methods to use for that data. In my level manager and loader I will handle translating the data into actors and physical objects on my own. Choosing the save method now is to minimize refactoring later.
I read your question and it is possible to use Json or even XML but I am asking you this. Why extension and representation type is important ? Do you want to view it outside of engine such as a web project ?
Unreal Engine has its own blueprint exposed Json plugin. You can use it. Marketplace plugins are really cheap, you can use them.
But you can also use Unreal’s own save system. It just creates you .sav file.
And all cases whatever you want to save, you need a plan. Especially for Json, you need to plan your structure. Because plugins are like this.
SetStringField
SetBoolField
etc.
They are not like “record transformation” or “record actor”. So, you don’t need to focus on extension. It is not really that important.
Any format can work but the simplest way to set it up would be to use Unreal’s savegame system.
To use Unreal’s save system with your example :
create a new Struct containing the three variables (Piece:String, Location:Vector, Rotation:Rotator)
create a new Object class, with a variable to contain an array of structs, and enable the variable flag “Savegame”
setup save system by creating an instance of that object, iterate all actors, fill up the array of structs, then use SaveGameToSlot
setup load system with LoadGameFromSlot, iterate array of structs, and spawn actors with location/rotation
Note: instead of storing the piece type as a String it would probably be much easier to store it as a Class, unless those pieces are not actor classes.
Pretty much everything else will require plugin(s), to serialize/deserialize complex variables (array,vector,rotator), and/or to read & write to files on disk which Blueprints do not support out of the box. There are free plugins to do that, but it doesn’t seem worth the hassle unless you need to be able to easily read the files externally. Serialization to non-binary format will also induce additional performance cost, and larger file sizes.
If you need external access, or if you really want text format for some reason, then JSON is probably most appropriate, as it is very widespread and has decent enough builtin support in Blueprints. It may not be possible to json-ify an array of structs directly, but you can create a new struct with a single variable containing an array of structs, then you can json-ify that, using node ConvertStructToJsonString.
I just realized now there are some new nodes to serialize json to files, so you don’t even need a plugin for that. However you might still need one if you want to check file presence or list files in a directory, etc.
Regarding converting json back to struct, it seems like the function to do that is still not exposed to blueprints. So when loading you’ll have to either iterate the json fields and do some conversions (floats → vectors and rotators), or write a small C++ function to convert the whole thing via engine utility FJsonObjectConverter::JsonObjectToUStruct
I will go ahead and save to the internal save game system for now, and work on the external saving and loading at a later time.
The main reason that I am saving the pieces as a string is that I have a data table of Static Meshes of the pieces of my level with temp assets for now that I will change at a later date once I make more advanced versions in Blender to replace them. It will also be more convenient to display the names of the pieces in the Editor Utility Widget for a level building tool. Since multiples of the same pieces will be likely used per level, I will be loading instances of the same pieces at different locations the overhead and graphics sizes will be smaller than saving the whole class every time.
The saving externally was for having the player make tracks that they can trade and challenge their friends with, similar to how Satisfactory blueprints are tradable.
I am unlikely to have much more than 150 objects in one map with about 25 different pieces that are used, but the system will be able to handle more than that with low load times. I am rebuilding an older game project that I worked on from scratch in UE5, so that’s how I can estimate the approximate sizes of the levels.