Should I clear arrays of pointers before saving struct to GameSave?

I suspect the error has not much to do with the issue.

When using SaveGameToSlot / LoadGameFromSlot, it’s only the UProperties in SaveGame class that are serialized / loaded. Those properties are :
TArray<FObjectRecord> ObjectRecords
TArray<UObject*> TempObjects
TArray<UObject*> PersistentOuters

TempObjects and PersistentOuters should probably not be serialized. They will just serialize as string refs, and cause the sort of errors you are seeing upon LoadGameFromSlot. You should mark those two UProperties as Transient to avoid saving/reloading them.


You say you call SaveData() on GameInstance. How exactly ? What do you do with the resulting array of bytes ? Do you create your own FObjectRecord and add it to the ObjectRecords array ? Doing so will result in creating a new GameInstance upon preload, which is not a good idea. Creating a new gamestate isn’t a good idea either, though there’s a better chance it would appear to work (but not really).


I still need more info to help more unfortunately. You showed how your saved objects are structured but the problem isn’t at that level. It’s most likely at the intermediate level which I can’t see.


If you create objects with Outer = GameState, and “move” these objects to GameInstance upon level change, either the objects will be destroyed anyways, or the engine is gonna crash on map change. Persistent objects should be stored in GameInstance that is definitely the right way to go.


I’m gonna try to get a simplified example working.