Development Blog‎ > ‎

Saving Game State

posted Feb 14, 2012, 11:48 AM by Mavrik Games   [ updated Feb 29, 2012, 9:02 AM ]
For the last few weeks I've been busy updating the site and creating a new site dedicated specifically to Astra. I've also been busy studying how to save the player's game state in UDK so you can switch maps without loosing inventory/status. As I mentioned in my last post, one way to accomplish this without actually saving any data is to just use streaming maps from a persistent level. It seems to me that this would work for relatively small maps, but given that you have to load each streaming map up front at launch time leads me to believe that this wouldn't be a practical solution for any game with more than a handful of levels.

Browsing the interwebs for a solution, I came across WillyG's page and was fairly impressed with what I saw. He's been working on a save system for quite some time, but he recently realized that there's already a Gem for saving data: http://udn.epicgames.com/Three/DevelopmentKitGemsSaveGameStates.html. This system serializes the pertinent actors/objects in the game using JSon. The idea is simple enough, but the implementation is a bit time consuming, but that's the way saving game state has to be.

The only drawback to the system is that the save files are in plain text - easily manipulated by the players. As WillyG mentions, you can modify the code a little to use binary files instead, or mangle the text, or a combination of the two, making it at least a challenge to hack the data. If you have access to a server, you can save the data online, though due to connection speeds, this may cause too much slow-down to use for simple level transitions. Using it to save a player's progress however might prove to be worthwhile.

WillyG's save system is much easier to implement, and therefore it might be a more viable solution to simple level switching than the full-blown level saving system Epic gave us. In fact, the Epic level saving solution actually uses the same ideas as WillyG's system (even the same functions), but they serialize all the dynamic data in the level beforehand, not just a value here and there, making it a more complete solution.

In the end, I think a combination of the two systems is probably the way I'm leaning toward. I'll try WillyG's simpler solution for player stats and inventory for level switching and Epic's full level saving system for player progress and game saves.
Comments