I’m working on an RPG and am looking to create a system (unless one already exists) in C++ that will take a complete snapshot of the game state. NPC locations, actor locations, NPC health, player location, weapon stats, etc. Very similar to how it is done Fallout/Skyrim. I would like to create a complete save state of everything going on in the game and be able to load that save state later on and resume exactly where everything was. Does anyone have any pointers on where I would start with such a project? I’m sure this is a huge question and can likely be done a number of ways but I’m not very familiar with how saving works in UE4 and if there is a way to already do this or if this is something I would need to build completely?
Actually, doing something like that is not easy in the slightest. UE4 built in save system lets you save a “SaveObject” into a binary file and also load it. BUT ONLY THAT OBJECT. You would need to find a way to store the world state into one of those, so then you can serialize it. To do something like that, for example for NPCs, you would add an array to the save object, iterate over all the game npcs, and save the relevant data(position, health, inventory) for each of those. Then do similar for quest info and for player info.
For loading, you iterate through your “npc data” array, and start spawning npcs from that.
Big RPGs are some of the hardest games for save systems, due to the amount of stuff that needs to be stored.
My auto-save plugin may help you with that; depending on what exactly you need to do it may be already what you want although I’m still working on it to also save UObjects and Actor Components, for now it only saves Actors and Blueprint variables within these Actors, but it allows you to snapshot the whole game world.
@vblanco
Thanks for the swift response. To make sure I am understanding correctly, are you are suggesting that I need to find a way to get all my world data into ONE SaveObject containing a serialized array with multiple child arrays or are you suggesting (if possible) that I have different groups (all NPCs, player, etc) and save each array into it’s own binary file? Is there any pros/cons to one versus the other?
Here is an image to try to show between the two different methods which I am describing:
@bruno I didn’t refresh the page and see your comment before posting this reply. I will check out the plugin right now, and see if it fits my needs. Thanks
EDIT: @bruno wow that plugin is super impressive, really cool. Looks exactly like what I’m trying to do. For now I am going to try to reproduce this myself, for the learning experience and so I can build it out to work specifically for my game and have the expandability that I need.
Method 2 is problematic to do, you cant save several different objecst that way. You could use save slots for that, for example, in slot NPCDATA you would save the npc locations, and in slot PLAYERDATA the player data. But doing it that way adds some complexity, the system is designed to save one master save object.
That answered my question completely. I was unsure if it was built to be used for one master saveobject or multiple. Thanks everyone