how do you keep score?

How do you keep the score current as the player moves through levels, for instance they score 1 in level 1, 2 in level 3, if they die at level 4 with no other points how do you keep updating the score across different maps.

Also how do you open different maps from other maps?

To keep score, just add a variable to the player character, turn it into an array and fill the entries according to the level.
When you load another map, which you do by calling the LoadStreamLevel function via blueprint, the character will keep his values.
Dont forget to add your additional levels in the levels panel, otherwise they wont stream in :wink:

Or even easier, make a custom game instance and save it to a variable in there. Game instances are persistent through level changes.

In how far is a custom game instance “easier” than just adding a variable to the character?

Because your character gets deleted upon level change? I mean if he’s using streaming levels, that’s one thing, but if he’s hard loading into another level, you will lose ALL variable information except for the variables found in the game instance.

It’s super easy to implement a new GI and will foolproof your variables regardless of if you use level streaming or hard level changing:

Make a new game instance(add a new blueprint with game instance for it’s class), open your project settings, click the all filter at the top left, search for game instance, choose your custom GI.

Open the custom GI and add the variable you want.

Within whatever blueprint is keeping track of the score, right click=>get game instance=>drag off of it and type “cast to” and make sure to select the cast to with the custom name you used=>off the output of that, you can get/set the variables that are within the game instance.

Many thanks for that guys, much appreciated

I dont think so. just tried it.
Added a variable to my character, changed the value in level one, then changed to the second level, and the variable kept its changed value…
Perhaps because the player character exists in the persistent level :wink:
(What do you mean by “hard loading”?)

If you have a persistent level, then you’re using level streaming and that means you don’t lose everything. A “hard load” is when you use the open level node, which you’re bound to do at some point.

For example: going from the main menu level to the game level. 99.99% of the time, these are going to be two separate levels and won’t share a persistent level with each other. In this case, you lose everything other than the game instance variables. Even in open world games, you’re still bound to perform a “hard load” change of levels. Look at games like the Witcher 3, there’s still some loading screens between zones. If you ever have a loading screen like that, you’re probably performing a hard load and therefore, you will lose all of your variable information, except for what is stored in the game instance.

1 Like

Thanks for that guys!