Just create a member in one of your classes (like GameState): UMetaData* saveGameInstance;
And only create it once (like in BeginPlay
, or on first save), and update save this one whenever you want (not a new object).
Even though, the correct solution would be not to use SaveGame for updating data. Whenever the user wants to save, you should fill the save object with the most recent data you want to save, run SaveGameToSlot
, and you should forget it until the next game saving or loading.
If you’d like to use meta_intArray
while playing, store it in GameState
instead, and pass it to SaveGame
only when saving.