Which data types can we use in the built-in Save Game object? Are we limited to primitive data types such as bools/ints/floats/vectors/strings and structs and arrays of those types? Or can we also use Object references? Hierarchies of Objects?
If Objects aren’t allowed, are there any standard techniques for correlating both live and destroyed Objects with their Save Game entries? I saw some sample code using GUIDs; I’m hoping there’s something better.
Also, when writing to the Save Game object, are there any thread safety issues to be concerned about? For example, if a large number of Actors had a custom event to save their state in Save Game, is there any fundamental reason why that shouldn’t work?
Your save game object inherits from the standard. I don’t think it’s possible to use the standard.
You can put anything in there you like, but I wouldn’t recommend putting your own data types in there. I was developing a game for 2.5 years, and spent about 6 months ( on and off ) hunting down a weird crashing problem, which turned out to be using my own data types in the save game. It’s because doing this basically turns your save game into a massive reference loop leak for the rest of the project ( hard to explain, I will try harder if you want to know ).
If you want to know which actors have been destroyed, you can just use an integer reference to them.
As for thread safe, that I do know. First thing is don’t use the async version of save game to slot. It’s only for large volumes of data and can’t handle more than one process using it at once. The standard save game to slot works great. I wrote a test with 100,000,000 actors all reading and writing to the save game simultaneously, flawless.
I still haven’t quite been able to completely wrap my head around UE4’s serialization model for Save Game objects. Is it limited to primitive data types, or can it deal with objects such as Actors, too?
Also, when you say I can “just use an integer reference” to handle destroyed actors, I’m not sure what you mean. Is it possible to assign a unique integer to each Actor that stays consistent between level changes, game instances and the like?
The serialization deals with the fact that you can make a save game with just a bool in it, and then two weeks later, add various other structures, and yet UE still knows it’s your save game, event though it’s not the same shape.
You can put refs to actors in there if you want, but what good will that be next time you load the game? ( the refs wont be the same ).
As far as the ints go: say you have a BP DestroyableTree. Then add an int variable to it, when it gets destroyed, it can put it’s int ID in an array in the save game. Next time the game loads, tree 46 ( or whatever ), knows not to appear, because it’s ID is in the array.
It really depends what kind of game you’re making, what kind of actors etc…