Download

Global Variables

I’m a bit confused about how to set up a global variable.
I need a “Level Colour” that can be changed in game by many different blueprints.
There are then many parts of the level that will have to change to that colour whenever the variable changes.
Any help is appreciated.

Global variables aren’t really a concept used in blueprint. BP is based around references and interfacing.

The best thing you could do is add a GameInstance blueprint and add it to your project. Put variables you want to be global in the GI BP and you’ll be able to access them from anywhere at any time. Just “Get Game Instance” and cast it to the type of GI you created and access all of your variables from it. The GameInstance is created and destroyed only once, so it will persist for the life of your game.

How exactly does that casting work?
Say I have a variable in the game instance called “LevelColourGlobal” and want all the boxes in the level to be the same colour, how would I set that up?
Which Blueprint would have the casting node?

Hello,
The britain did a short video about that : https://forums.unrealengine.com/showthread.php?54335-Gorilla-Gong-Tutorials (don’t forget to thanks him if this usefull to you ^^)

More infos there https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/index.html where is shown how save your game.

Thanks very much. The video helped a lot :slight_smile: