Gloabal Variable aKa Second map needs to know if its true or not

Its i weird title, but what i want to know is, what is the way to archieve the following:

In the first map i trigger an event, like activating a radio, now the player goes to the next level, now the next level needs to know if the music was activated in the first map. Whats the way to archieve this, i am right now looking at an save/load system, but is this the only way to archieve this? in case saving the state actually works for that.

I also thought about creating 2 different “level2” maps, depending on if something is triggered or not, but then i would need like 20 copies of the same map, because the second level have to change, depending on what event was triggered on the first map. The map/s itself would be the same, exept for the part that the one is playing the music/or what ever was triggered before.

I appreciate any help :slight_smile:

Hi,

Use the Game Instance class! It will preserve your variables across levels, it only gets reset when you close the game.

Using it is easy, you just create the variables you want to keep in it and update them by casting to your game instance class. You can retreive their values using the same method. Don’t forget to tell the engine to use your custom game instance: go to project settings->maps&modes and set the game instance to your own one.

Search Game Instance for additional info about using it.

I hope this will help you.

Yeees it does !

thank you so much :smiley: