Saving Record Time for every level in a structure?

Im working on a platforming game with over 100 levels.
In those levels you have a stopwatch/timer that stops the time in that you beat it.
I would like to save and display the record time for each level but im having problems.
Right now my GameMode runs the timer with a timespan variable that gets turned into a text variable,
my player widget then takes it and displays it on the screen.
The Level Goal BP stopes the timer and brings me to the next level.
I would like the Goal BP to then take the stoped time variable from the GameMode and save it in a structure or something. The problem is tho… how do I save the time under the correct structure variable. Also… is there a more efficiant way to store all the records for every level?

If anyone would like to have a screenshot of anything then pls ask!
Thanks in advance!

  • create a struct to represent data you want to save: level name, time elapsed, points scored, etc.
  • count time for for the current level in the Game Mode as you do
  • in the Game Instance (that persists throughout the game session) have a Map (a much cooler cousin of the humble array) variable Name | Struct
  • when the level is over and better score has been achieved, make a struct, send it to the Game Instance and have it add it to the map (or an array)
  • when the new level is loaded, you can access the Game Instance, read the content of the map / array and create the appropriate UI using widgets

Eventually you’ll need a save game system if you want the date to persist between game sessions as well. You can use the very same map / array in the Save Game object.

Will I have to create a new variable for every Level?

Here’s a quick mock-up of how this could be set up:

The Game Instance can Add New Highscores, and check existing Highscores:


When the level is over and you need to see whether a new entry is needed:

You do not need to use Timespan, ofc. Use whatever data you’re using now.

I’ll just add that I’d send a struct to the Game Instance and have it check internally whether this entry is worth adding. The player character / controller / currently played level should not really care about this kind of stuff.

Thank you for your awnser but… cant I only save the record for one level in a map?

No, only 1 map in the Game Instance.

There is no limit to how many elements a Map can store (there is but that’s a big number). Map consists of Key | Value pairs. The key must be unique. If you add the same key again, the value gets replaced:

This seems to be perfect for this. You do not need to populate anything in advance - simply start adding level names and their structs to the map as you play.

If the entry does not exist, it will be created. If it does exist, its value will be replaced.

And, most importantly, you do not need to look up anything (you would with an array if you replay level 5 and you have 10 levels); and you will not get any duplicates this way - since Map keys must be unique.

Oh ■■■■ I got it working! Thank you so much! ^^