Where to store variables per map?

New to unreal, I have multiple levels and each require you to get a different amount of coins to win and move to the next level. Where should I be storing the CoinsToWin variable, and how do I properly access it?

Hi, rslink

I guess it’s an easy-to-do feature. All you need is a structure and a integer variable.

1, Create a Structure and a BP(Usually Character BP but i create an actor because there is no need to do movement logic for this case.)

2, Then in the Structure, you should store two variables: LevelName : Name, and CoinsNeededForPassLevel : Integer.

3, Next, in the other BP(For Example your CharacterBP), you need to create two variables: Coins : Integer, and An Array Based on your Structure. Add item in the array about your LevelName and coins you want to pass each level. Then write like that.

The basic logic is: if some condition is triggered (like you finished the level), then compare current level name to your array’s each member until find out the current one, then compare your coins collected to the coins that required for passing the level, if your coins are greater or at least the same amount of that, then get next level name in your array based on the next index. and open it.

Hope that will help!

This is what the GameMode is for. The GameMode defines the rules of your game (the GameMode can be different from Level to Level though)

If you touch a coin, you simply use the GameMode (to be more specific your subclass of it) and add a coin to it (which is represented as an integer for example)
When adding a coin, you also check if it reaches a certain threshold/number to win the Game.

To define the Amount of Coints needed, you can either subclass WorldSettings (per Map settings) and add it as a variable (C++ needed), you can store it in your LevelBlueprint (you have to communicate with your GameMode here, probably through Interfaces or Event Dispatchers) or you can add an Actor in the World which stores this information and sends it to the GameMode automatically through BeginPlay.