Saving default variables in another Blueprint

Hello unreal Community,

I have a question regarding default variables.

I have some default variables inside a blueprint widget, which I can’t access unless I create the widget.
Now I want to use these variables in another map, where this widget will never be loaded. Since its an array I don’t want to create those variables and its values multiple time.

My question is:

Is there a way I can set these variables once in a specific and then access them from different parts of my project eg. widgets and actors?

Kind Regards Alex

I think what you’re asking, is - is there a way to have global variables.

I’ve thought about this for both blueprints and normal coding and i think the best answer is this -

In your game mode or perhaps your level blueprint you create a new blueprint, called say, GlobalsBP. Inside that you create all the information you might want.

Then you also create your other objects inside your game mode or level blueprint. your other objects will have a variable of type GlobalsBP inside them. After their creation, you set their variable to be the instance of GlobalsBP that you made in the main class - the level BP / game mode.

This is how my AI work in my game - an AIManager is updated with their information when they are created and is also sent into each AI as a reference. The AI then listens to the manager class for commands. I also use the same method to store a global list of all world cover etc etc.

I don´t underestand what u mean by:

“Then you also create your other objects inside your game mode or level blueprint.”

And by create do you mean I have to make a node and let this node at the start of the game?

Kind Regards

so you create everything in one place. Class A contains your globals and you make one of it. All other classes have a variable of type ‘Class A’ in. You set this variable to be your one instance after you create them.