How to save an Array?

Hi.
I am trying to save an Array. It does save one value. But in doing so it resets all the other Int Values in the array back to 0.

What i am trying to achieve is write the current levels score to the array that is save. It does work in the sense that it saves the current level score. But when it does save it, it resets all the other Index to its default which is 0.

Any help would be appreciated.
I followed tutorials on youtube about saving multiple actors but somehow what was done there i cannot translate correctly to my setup.

Perhaps due to a lack of understanding.

http://s3.postimg.org/cxtv22i8z/cast.jpg

Are you using a foreach loop to get each array entry in your blueprint to update to the array in the savegame?

Before save to slot, check the source array in your blueprint isn’t empty (Length !=0) and if it isn’t, make sure the savegame array is cleared (using Clear array function). Then foreach member of the blueprint’s array, Add it to the savegame array, then do save to slot. If the source array in your blueprint actually is empty, there’s no point to save that array, but you still need to decide whether to clear the saved array so that it matches with the current gamestate.

If you need to be sure that the entries are in the exact order in both arrays, try usng Set Array Element which lets you pass in the index value, and has a Size to Fit tickbox.

In my short knowledge in your blueprint sequences
you always set all the each value in “Level Score Reference” with “Level Score” of Target(may be SaveGame)
(Maybe copying not referencing)

Check out all the each value in “Level Score” of Target before “Set Array Elements”

Hi.

Apologies. I wanted to delete this question just now and saw you guys posted. Ethan and Tomofnz

I did find my issue. The reason my array was not saving is because i had a event begin play create save game object in my blueprint. Noob mistake i know.

This overwrote my savedgame information.

This tutorial helped me a lot.
link text

1 Like