Download

Get/Set variable from 1 blueprint to another

Been trying to figure this out for weeks. Watched many youtube videos including virtus series and haven’t seen a straight forward answer to this:

BlueprintA has variableA which equals 2
BlueprintB has variableB which equals 0

I want variableB to equal variableA

What do I need to do to achieve this?

I know this has to be simple but I just can’t figure it out for some reason. Every other program language is pretty simple as far as this goes.

Its a real simple question, that part’s true. But because Blueprints copies aspects of C++, the answer isn’t simple, its more of a puzzle. To learn all your options regarding BP comms watch LiveStreams like this. But for now here’s two options:

  1. Store a shared variable in Gamemode that both BP’s can access by using the Get Game Mode node. You will need to Cast To the current Gamemode (check in Project Settings -> Maps & Modes, to get the active Gamemode name). That way neither BP needs a direct get / set, they can do it all indirectly.

  2. Use the Get All Actors Of Class node to get a reference to BlueprintA & BlueprintB… Then you can directly access their variables. Caveat, this will only work properly if there’s exactly one instance of BlueprintA & BlueprintB, otherwise it isn’t practical.

I’ll have to try that.

Yea what I’m doing is creating 25 instances of a blueprint in the game world, and then I need to get randomly generated values off of them. Thanks for the help! +1

EDIT:

Just to let you know the first tip helped me get over my dilemma. I watched that video you linked before, but I’m going to have to watch it again because I clearly missed some big tips.

No worries. Just to add… Get All Actors Of Class will still work for all 25 instances (you can access them by using Get and an index (0-24) or using a ForLoop etc). But if you’re trying to PAIR a specific Blueprint to another specific Blueprint it may not be the best option. You can still TAG Blueprints too though (Tag = built-in Class string) as you create them, and then use Get All Actors With Tag to get the specific ones you need when you need them.