it looks to me like your saving the locations and maybe even a reference to them, but that won’t help if your loading or reloading the level. when you load the level it is as if the cubes never existed because in this instance of the level they never have. when a level is exited then everything in it is destroyed including your cubes. think of everything you make as a blueprint (real life blueprint to build something) that tells how to make the item, then you create a house from that one blueprint, you then add furniture to the house, and finally you destroy your house and build another. would house two have furniture? nope.
so then how do we fix this. you have the basic info of the actors you want to exist in the level. you know its a cube and you know its location. so all you need to do is to spawn it into the level. to do this you need a event that says we’ve loaded the level so now we will spawn the cubes, lets go with on begin play of the level for simplicity. so on begin play we get the save data, get locations and classes to spawn, then we run some loops to spawn the cubes. the psudo code would be like this:
- on begin play
- load save data
- get locations array
- for each location (this will run the loop once for every element in the array)
- spawn actor of class (set location based on array element)
theres a million other locations you could run the script and theres merits to each, theres also modifications you can make to the script itself to accommodate different actor types.