Is there a way to make a variable's values dependent, in blueprint?

Let’s say I have 2 public variables on my blueprint:

  • Target (can be Door, Light, Gun, for simplicity)
  • Interaction (should depends on the Target)

So let’s say, you choose “Door” as the Target, so then the Interaction should have selectable values as “open”, “close”, “toggle”.
If you choose “Light”, you should have “on”,“off”,“toggle”
if you choose “Gun”, you should have “apply”,“buy”.

Right now, I’m just using an enum with all the interactions, and use a switch inside the blueprint to differentiate on what to do with the targets (meaning you can see all the interactions (on, off, toggle, apply, buy, open, close) even if you just select “gun”, where you should only see apply and buy).

Mainly, I wanted to make it, so instead of this you pass in a map, so the first part of the set is the Target, and the second part is the Interaction, but AFAIK, you can’t loop through said map.

Is there a way to change the values of the “Interaction” variable, depending on what target you choose?

The goal is to call the “interaction” on the “target” (with the map idea, to have multiple targets and call the corresponding interaction on them).

1 Like

The goal is to call the “interaction” on the “target” (with the map idea, to have multiple targets and call the corresponding interaction on them).

Sounds like you’re describing an interface without knowing about its existence. Because that’s what they do - we send a message to some actor and it decides what to do with it.

No need for a map (and yes, you can loop through it but it is not necessary here).


So let’s say, you choose “Door” as the Target, so then the Interaction should have selectable values as “open”, “close”, “toggle”.
If you choose “Light”, you should have “on”,“off”,“toggle”
if you choose “Gun”, you should have “apply”,“buy”.

How is this part supposed to look like? Like a right click context menu in a point & click game?

1 Like

I know what interfaces are, I’ve been a developer for 3 years now (wohoo), I’m just new to UE.
I did make an interactable interface, but I think you misunderstood me.

My example might’ve been hard to understand so I’ll try and come up with something else with direct examples.

Let’s say you have a button, it has the interactable interface I mentioned.

What I do right now is, I pass Actors to it, tell it what kind of interactable it is, and what method I want to call on it.

So, if you choose “Door” and “open”, it will run the “open” function on the door (rather “call the ‘open’ event on it”, but for simplicity, it calls the method).

So, just to showcase the example: the selected button has the door next to it in the Triggerables array

I let it know that its a door (for easier ‘Cast To’), and that it should run the Toggle function on it.

The middle button does the same thing, but calls the “close” function on it:

So, I can just pass multiple actors(doors) to it to open multiple doors, or close/toggle them, etc.

And then, just for a non-door approach, this button toggles the light next to it, also passed in the array.

So if I had to translate this to PHP:

foreach ($triggerables as $actor) {
    $actor->$action(); // $action comes from the dropdown 'Trigger Interaction'
}

to call the method on the actor. This is what I’m aiming for basically, dynamic method calls on the actors.

I think this example will be much more clear, yesterday I managed to make it, but still not as reusable (and dynamic) as I want it to be.

The current button bp (with the interact interface on it) looks like this, just as a guidance:

PS: ignore the “Trigger Me” variable, it is not relevant in this discussion.


BP_Button has BPI_Interaction interface


BP_Door BP_Light BP_Gun have BP_Trigger interface




set BP_Button trigger setting



If you want the options for the second value to change based on the value of the first Target, you can only select options that can interact with the Target. This is relatively difficult to achieve in the editor, and you can only filter out incorrect configuration options through code.