Save and load placed Actors in the Editor

I have a level consisting of a road and a few vehicles (which are blueprint assets that I created). I’d like to create different traffic scenarios by putting vehicles in different positions and setting their variables, without creating a separate level for each scenario. Inside the editor, how can I save a set of placed actors to a file (or directory), and load them to the level later based on which scenario I want to work with?


You have a couple of options, depending on what you want to achieve.

  • if you do not need to make changes during run-time, if you do not need to save anything that changed dynamically during gameplay, you may get away with setting up a DataTable and keeping all the variables inside.

For this you will need to read up on Structs and Data Tables

In practice, you would create a struct for each traffic scenario. Each traffic scenario struct would contain arrays of other structs relating to vehicles present, their state, road layout, conditions and any other variables you may need. You can create this data in a worksheet (anything that can export a *.csv file) or directly in the editor.

  • if you need to save something that has changed during gameplay, you will need to use a Save Game Object. You will still need structs, most likely, otherwise this will become tedious much quicker than you expect.

In this case, rather than holding rows of DataTable structs, you would position your vehicles around the map, set their variables, run the project and save the state of the vehicles to a Save Game Slot by name. This will need to be done in loops. Rinse, repeat and save a different layout, this time round to a different slot. You can then load a save game from a slot and respawn everything.

Save Game Object would work for both scenarios, of course. DataTable allows you to tweak a lot of variables quickly (especially if you do in excel) but the ability to set everything visually in the viewport has its advantages as you can imagine.