Possible ways to save a generated level?

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