Send a boolean variable to many blueprints?

I have created two actor blueprints in my content browser (Blueprint A and Blueprint B). In my level I have one instance of A and as many as I need of B. The number of B’s will change from level to level.

I need to send a boolean variable from A to all of the B’s. Is there a way to do this without creating a reference to each B?

Please help. I am really stuck here.

Hello Fjellgnu,

There are a few ways you could do this, some more efficient than others. If Blueprint A happens to be your GameInstance, PlayerController, Controlled Character, or anything special such as that, this will be much easier to do. The easiest way to do that would be to have the Blueprint B store a reference to Blueprint A instead either during its Construction Script or on Begin Play. This could be done through the GameplayStatics functions such as Get Game Instance, Get Player Controller, Get Player Character, etc. You could then use that reference to refer to the boolean at any time.

If Blueprint A isn’t one of those easily referenced types of classes, you could also use Get All Actors of Class, search for all actors of Blueprint A’s class, and then store the reference that way. This is the less efficient way but it would still get the job done.

If you explain exactly what these blueprints are and in what situation you would need to be referencing the boolean I may be able to give a better solution for that particular situation.

You can also use an event dispatcher.

Go to the class that you want to broadcast the boolean and add an event dispatcher and add a boolean input to it, then call the event wherever you want. Then go to the class that you want to receive the boolean and on begin play assign the dispatched event to an event from that class. And now every time you call the event, all your actors will receive the boolean without having a direct reference to the broadcasting class

Blueprint A is an on/off switch. Blueprint B is a trap for the player. I want to use Blueprint A to activate/deactivate all the traps in the level at the same time.

Thanks! I’ll try this out!

DUDE!!! That works!

Much appreciated! Thanks a lot!