Hi,
I’m trying to figure out how to save changes to maps, my game uses a grid based building method that uses 100x100 scaled blocks and I’m tring to figure out how to save the player’s changes, for example if a player places a block at a specific location or builds a specific structure on their island how can I get that to save and then load back up when the player enters the game again. Pretty simple idea (at least I thought it was simple until I tried to implement it) but I figured I’d ask here, at this point I’m about ready to catalogue each and every block in the level when the player saves and then read that information and place each block individually when the player starts the game, probably not the most resource friendly solution but if it’s not possible to just save the whole level and reload it then that’s what I’ll be doing.
With love, some random dude making a pretty lame game.
I know what the save game object is and how to use it, I already use a save game object for my games settings and will be using one to save player progression, what I’m looking for is a way to save any changes made with the games building system. The building system allows players to spawn and delete actors in order to build in the game, I’m looking for a way to save these spawned and deleted actors and load these changes to the world when the player starts the game again, the method I currently have (saving all the actors in the world on exiting the level, deleting all actors upon loading the level, and then respawning the saved actors) is just causing a full game crash (for obvious reasons)
I’m afraid this is the only way to do this, any actor that spawns dynamically cannot be baked into a map in-game. And they should appear dynamically during the loading of the game. At least blueprints don’t allow that.
If the player cannot delete the actors that were originally, then here you can simply save and load separately on top only the actors that the player has spawned.
After some fiddling I was able to somewhat achieve what I was looking for, I have my actors tagged with a specific tag, upon saving that game takes all of those actors with this tag and saves them to an array along with their transforms in a separate array, then proceeds to delete and respawn actors in accordance to the saved arrays. However, it would seem that actors added in during the game aren’t being saved, I think it might have something to do with the tagging of the spawned objects however I’m not sure as of right now.
Any blocks deleted on the first play through are not spawned in the second play through as intended.
Any blocks placed in the first play through are not spawned in the second play thought which is not intended.
And on the third play though the entire map breaks
The map breaks on the third time for the same reason spawned blocks aren’t saved and loaded, however I’m unaware as to what exactly is causing spawned actors to not be saved like the actors put in the game before playing.
If you want to save exactly what the player has changed. I would recommend doing the upload in several steps. Save information about actors that have been removed and that have been spawned. When loading a map, you load the original map with all the actors, and first you delete those actors that were removed, and then spawn those that have been spawned. Save to different arrays, and check what you write and what you load. I think you have something similar and implemented. Check if you are overwriting the same save slot. Sounds like this is happening.
So what you’re saying is that I need to do is check an array of saved objects against the map’s original state instead of saving the entire map and deleting the map all together to replace it with the saved map? (If that makes any sense)
This makes sense if you want to reduce the load. In the first case, you save all the actors and spawn them, and in the second case, you delete and spawn only those that have been changed by the player.