Set Variable By Name in BP

I need to update a variable on several BP Classes sharing a common Actor Tag (ie Group_01). All the “Group_01” BP actors contain a common variable named “GroupSwitch” (bool).

As you can see, I’m able to get all the actors with the common (Group_01) tag but I’m not sure how to set/update the “GroupSwitch” variable on all the selected actors.

I know I can “set a variable by name” (ie GroupSwitch) in C++, but do I have any way to implement something similar with BPs?

One possible use is to create lighting scenes, where a lighting artist can just Tag the BP lights into corresponding scenes and create new Scenes (Tags) in-editor without any BP coding required.

Like this

But if you used


you wouldn’t need to cast.

1 Like

As I understood It sounds pretty easy. In for each loop you need to pull out Array Element and setup this variable

Hi @ClockworkOcean.

Unless I’m missing something, that would only work if all the BP actors with “MyTag” are the same “MyBP” Class, but in my case the “MyTag” actors use different BP Classes not just “MyBP”. What they have in common is the use of “MyTag” and “MyBool” naming convention.

You can check if those actors have implemented a valid blueprint interface and use that to avoid casting several classes.

With FindPropertyByName?

 if (TargetObject->GetClass()->FindPropertyByName(VariableName)) 
     TargetObject->someVariable = 1; 

Would be cool to just pass a string ( “VariableName,Value” ) and on the other side use Parse Into Array :thinking:

1 Like

Thanks @pezzott1 ! Looks like the BP Interface will do!

BTW The Cpp alternative was from here Get / Set variables by Name | Shooter Tutorial

1 Like

Thank you!!!

@pezzott1 Do you know If it’s possible to catch the same Interface Event on both the Parent and Child classes? I ask because when I catch the Interface Event on the Child class it no longer fires on the Parent. I’m trying to run a function on the Parent Class first and then another on the Child.

Like this?


You can have you regular Event → Call ParentEvent and have the interface just call the Event of that BP and run everything as it was.

1 Like

Thanks, I ended up using Override Function for my use case.