Using Variables From Different Blueprints

Hello, I was wondering is there any way to set a variable in one blueprint, and then use that variable in another blueprint?

This is for a school project so HELP PLEASE.

Thank you

Nyck,

Yes there is, and it’s not all that involved. Basically you have two blueprints running and your looking for a way for them to “communicate”. Where how intricate the communication level is up to you.

The first thing you have to have is the Blueprint’s object reference that you wish to get the variable from. No matter what method you wish to use, this is required.

So use the node of Get all Actors of Class, or Get all Actors with Interface,

These nodes will return to you, an array of actor references. To keep your life simple (so you don’t have to try to figure out which reference is the correct one, that you wish to get the value from) ensure that the blueprint that you wish to get the variable from, is the only actor of that class in the level. Hence when the blueprint node provides the array to you, it should only have 1 Actor reference, which you can check easily.

Create a function in the blueprint you wish to get the variables value from, that does really nothing more, than enter, and then return the value of the variable. Hence you will need to make a function, then create a Return Node, and have the Return Node, have a pin for the value you wish to return. Then in the function, just set the Return Node’s value to the variable.

Fastest Method.

Now in the blueprint you wish to get the value returned too.

  1. Right click, to get the context menu up (uncheck that silly Context Sensative box, it hides too much).
  2. Locate the name of the blueprint that you are getting the value from
  3. You should see the name of the function there, that you created to return the value
  4. click on that function to get the node.
  5. Where you got reference to the blueprint, just wire that into the “Target” pin.

So what we have now, is that Blueprint A (the one that we are getting the value from), has an exposed function, that you can call from Blueprint B (the one we wish to have the value), and you have the reference to Blueprint A, in Blueprint B, have wired up the Target pin, so that that Blueprint VM knows what blueprint to call (i.e. it knows not to call your Blueprint B, which is the default, and you can see that, by the fact that the to call, filled it in with Self as default). And that the node for the Call to the function, has an output pin, with the same name as the name you gave the value for the Return Node in Blueprint A.

So just wire up that value to a Set of a Variable in Blueprint B, and your good to go.

There is another way to do this with direct access to the variable, but the blueprint editor likes to blow sky high when you do that, so I don’t suggest it. Just make the function in Blueprint A, Call it, and get on with getting on!!!

hope this helps

Inc.

Thank you very much! Helped a lot :slight_smile: