I have been writing a saving system that relies on the SaveGame flag and the FArchive class hierarchy.
So far I can save any actor in my world and restore it. However, it seems like when serializing an actor that has a member that is still default-initialized and has the SaveGame flag enabled, it will NOT get serialized.
Why do default-constructed members with the SaveGame flag not get serialized when calling serialize on an actor? Also, how can I change that?
Upon trying to load all actors in a level without opening the level again (simply search for every actor’s save-entry and restore his data), I have encountered that default-initialized members of an actor or his components, do NOT get serialized.
So if my health default value is 100, I then save my actor, then get damaged to 75 health, then load that actor again, he remains at 75 health. Other values work correctly though.
If I get damaged to health 75 first, then save, then get damaged to 50, then load, my health gets restored to 75 though.
This is not a problem when actually opening the level first, as a) values get stored when changed from default and b) values get default-initialized when the level gets opened. So, when loading a level anew, there is no problem. That’s why I have taken so long to encounter this problem, as I only encountered it when trying to implement quick save and quick load, which does not make use of re-opening a level.
I have been debugging and logging my code a lot, so errors on my part seem to be non-existant in this case (95% sure).