How can i use a global variable in unreal engine so that every blueprint in my project can read every variables without casting or “get actor by class” nodes . why even they add casting ? why cant they introduce true global variables like any other programming language ? . Is there any way in engine or any plugin or any hacking/modding to make it easy for everyone (at least for beginners)…
There’s a paid plugin on the marketplace. These variables are global and don’t require casting.
Are you talking about global or public?
global , sorry my mistake
That’s a big no-no. Only because languages allow them, it doesn’t mean you should use them.
Hi,
Should you wish to make use of variables between blueprints and are unable to cast to that blueprint there is a solution.
Make a Blackboard, you can find this in the AI section. For illustration purposes I called mine “GlobalVars_Blackboard”
In any blueprint that you wish to access a “global variable” use the “Add Blackboard Component” and then select your blackboard. You can add your blackboard to as many blueprints as you like but I’m sure there will be some performance drawback (not tested or measured).
From the “Add Blackboard Component” wire the “Return Value” terminal to either a Get or Set Value as Bool / Int / Float / …
You will need a Key Name. Use the “Make Literal Name” and type in the name of the variable and you’re done.
I know this is a devisive topic and I’m not debating whether they should or should not be used (valid arguments for and against) this is simply a “How To” should you want to use it.
