How to go about level Highscores and savegames


I am a bit stumped. I looked at Tappy chicken example but i don’t feel its applicable and if it is i cannot translate what was done to what i need.

My setup is like this.

I have a HUD blueprint which opens the end of level interface displaying Next, Retry, and the current level score.
I have a save Game Blueprint.
A controller blueprint.
Then i have 3 pawns. Once one reaches the end of the level the game continues but you possess the next pawn. Each one has their own health variable value.
My HUD blueprint contains a Time value.

So what i want to achieve is the following.
Once the first pawn reaches the end, i want to get the current health value and store it.
Second pawn reaches i want to add that health value to the first. Repeat for pawn 3.
That should then create a value of combined health values.

Once the third pawn reaches the end, the level ends and the time stops and the menu comes up.
I want to then take the 3 health values and add it to the time value.

The result of all values combined is the score.

That Score must be stored and saved. Because if you load the game it should check what Level1 Level2 Level3 etc. score value is.
Those values determine if your level selection menu is displaying how many “stars” you unlocked.

I have tested the functionality of displaying things according to score etc.
My issue is i cannot understand where should i be placing my Health values and where i should be writing it to add them together on end of level.

I do not need spoon feeding. But i would really appreciate some guidance as to what to aim for. Because right now, i am not sure if i should be creating many variables like Level1Score, Level2Score etc. Or create an array and call those values from the array. Or even if it should be in a level blueprint, an actor blueprint or where to place them.

If anyone can point me in the right direction it would be much appreciated.

For something like this I would use an array to save the overall score for each level and using the array indexes to determine the level it corresponds with.

Something like this:

I have done two tutorials on save game data, you should check them out. They might help, you can find them on my blog. (Link in my signature)

Thx @pattym

I still am a bit confused as to where to save the accumulated health variable.
Not sure if i add the variable in the HUD blueprint, or the savegame blueprint or both.

Because the variable will be called in the main menu blueprint, at the end of every level on the LevelEnd Menu.

You should keep your health wherever you have it now, but then at the end of the level when you calculate the full thing into a Score, you do the part of the BP that’s in the separate box as shown in PattyM’s screen. You then feed the Score int from that level into the ‘Item’ of the ‘Set Array Elem’ for the Scores array as shown in the screen. Index is the level you want it saved for, I just have that in my HUD and set it through a cast in each level’s beginplay event to match the level number. Depending on how you have things set up, you may have to come up with a workable scheme to match.

@pattym @Gooner44

Thank you. Finally got to the point where i could work on this.
I managed to save my stuff. I used the picture tutorials on Pattym’s Blog.

The only think i noticed is that if setting up the save system in the construction script then i get errors about cannot save due to external map source etc.
Moved the blueprint to normal even graph. Finally work.



I spoke to soon.
Still have an issue. Its seems that the save data is overwriting the entries.
I followed the Video tutorial now of @pattym but i cannot use a Level Blueprint system. Mostly due to not wanting to copy and paste stuff for every level i make.

Any advise would be very much appreciated.

This is my setup.
On begin play the Level Blueprint says I am Level “number” 1,2,3 etc.

In the HUD blueprint
Begin Play - Create save game object - Set SaveGameRef
Then another section that gets the current level, and saves it to the savegame.

However, every time i start a new level… it does save the score, but in doing so it sets all the others levels scores back to 0, only retaining the last level played.

“Set Array Elements” don’t work for cast to arrays. Save the cast to array to a variable in your had as a reference. You then set the index of the reference and proceed to set level score in your save game object to the reference variable.

I’ll try post a screenshot.

Thank you. I looked at your tutorial again.
You actually explained that here at 21:49

I don’t fully understand though. But i will try setting it up using an Array reference to save instead.
Will post as soon as i did this.

Thanks for all the help and also your Tutorials @pattym :smiley:

Ok. Im not sure if i just did the exact same thing.


I am struggling to understand the concept of what is actually happening. Basicly the way i understand it.
I Cast to savegame. Get the Array. Set that Array to the reference array. Then set the reference item to the corresponding Index. Then Cast to savegame and set the array to the reference array. And save.
Which actually to me seems to be exactly what i did before but just a longer way of doing it with the same result.

It does save the current Index of the array but then sets all other index items back to 0. :confused:
Normally i dont like being spoon fed and i apologize for being a pain in the ***.

I think this concept is a little above me atm.

It seems right to me. I’d try enabling the “Size to Fit” on the set array element though. Also check the reference array to see if its actually getting all the values.

Hmm. So after adding some debugging stuff i discovered what the problem is exactly. But still unclear how to fix it.

When the Map is loaded, it checks what is the current value of the item in the array. It returns 0.
When the Map is finished after it calculate the value it checks again what that value is. Then it shows the correct value.
But every time i load the map or restart the map the value in the savedgame object is 0 again.
I also checked if the reference array is getting the values. It does.

But due to the savedgame array reseting on map load, it just sets the ref array back to 0 at the start.

So i am assuming its because its not actually saving the value. Its only updating the savedgame blueprint, but not retaining that value.


Thank you for your patience.
I started getting frustrated and decided to organize my blueprint better. While moving everything and commenting stuff, i noticed this small little event hidden between everything.
It was On Event Begin Play create save game Object.
That event basically reset my savedGame every time i started a level.

I deleted it, and now my savegame information is retained.
Once again.

Thank you for all the help.