How do I open a door with multiple switches?

Hey guys so I have a door mechanic which opens and closes, I also have a switch blueprint which makes it for a power box that the player can interact with via an overlap collision.

I want to know how if I put 3 of these powerbox BP’s accross the map that if all 3 are overlapp interacted that it will open a door, I heard something about Booleans but I am not that good at BP’s, if someone could answer and maybe show some screenshots on how to do so that would be great! I am on UE5.

This is the simplest method I can think of:


On the switch, make sure to make the player unable to un-interact with it. Make it a one-way interaction.

In the door blueprint, make sure to have an array of switches that it’s linked to, and a bool for whether the door itself is open. Make sure associated switches array is visible so you can set it in the level editor.
image

As well as that, also have a bool in the switch bp that records whether or not it’s activated.
image



The actual action of this happens on tick in the door blueprint.
image

First, we go through a do-once node- this is reset everytime the door doesn’t open, so the door will only open once. You wouldn’t want a door opening animation to start every frame that the door is open.
image

Next, we set Open to true. It’s easier to assume true with this node and set to false if it isn’t rather than assume false and set to true.
image

After that, we go through all the switches associated with this door, and check if any are NOT activated. If any aren’t activated, set open to false, and reset the do-once node.

Finally, after the for each loop has completed, we check whether the door is actually now open. If true, do whatever you want to happen when the door initially opens.




Here’s the entire function:

Well you’ll want to add a boolean variable to the switches.
When interacted with it gets set to true or false.
Then when you use the door it can Get All Actors of Class (switch) and check that they all have that variable as true. If they’re the only switches in the level that would work.

But I think you want the final switch to open the door, so that would be a little different.


which array would I make the “switches”

The type should be “powerbox”.
You can make any type an array of those types by clicking on the shape next to the variable type in the detail panel of the variable.
image

I notice your detail panel has the variable tab collapsed, so you’ll want to open it to see this.


so like this?

Exactly so.

Make sure to do what’s called camel casing:
Instead of naming it “associatedswitches” name it “AssociatedSwitches” or “associatedSwitches”. With blueprints you can even just use spaces to make “associated switches”.
It makes reading your blueprints much easier.


this is what i got so far, what blueprint joins the array node to the NOT Boolean.

That would be a boolean variable within your switch blueprint.
The value should be whether the switch is activated or not.

Also, you can double click a line to add a re-route node. That’s what I’ve used to clean up the connection between SetIsOpen and the reset node.


How do I connect it to the arraynode?

I need to show you this, a lot of it is confusing, do you have discord? Add mine Roasty#4709

You drag off the array element pin that’s in the for each loop. A menu will pop up, and in there you search for whatever you named the activated variable in your powerbox blueprint.

You have to create it.

How do you mean exactly?

You need to create the boolean variable called activated in your powerbox blueprint.

The for each node iterates through all the elements in the array “AssociatedSwitches” that you’ve connected to it. For every switch in the array, it will trigger the loop body. Whenever it does that, the array element will be a switch.

Whenever you drag out from the array element, you’re using a reference to that element. In that search, it will show all variables and functions that object has.

If you were referencing your door blueprint, you’d be able to get stuff like “time to close” “key needed?” “locked” and even “AssociatedSwitches”. You can experiment with this using the “self” node- it references the object it’s in.