Multiple buttons > One door

Hey,

Incredibly noob question here and I’ve been trying to see if I could find the answer here but it always seems to be something a bit different that I haven’t quite been able to use.

I’ve set up a couple of really simple blueprints for a door and button (buttons can be activated by one of these - Shooting it, stepping on it, pushing a physics object on it… just using the “collision responses” for that).

Now, this all works fine when there’s ONE button linked to ONE door. But as soon as I want a multi button setup it will obviously just open once one of these buttons are pressed with my current setup.
I gather I’d probably want to set up a Boolean variable in my button (or maybe it should be in the door blueprint???) to only trigger the door opening once all required buttons have been pressed.

I’d really appreciate it if anyone had some time explaining how you’d set this up in the easiest way possible while still keeping this very flexible so I could set up any number of these buttons for a door without having a hard number of buttons I have to use and create new blueprints for every new case.

Here’s a screen of an example set up I want with 3 physics cubes that have to be pushed to the buttons to open the door.

when the buttons begin play, they can call a function on the door, called SubscribeBtn, which adds a boolean to an array inside the door, and returns the index of that boolean, which the button can use to set its ButtonID. then when you press a button, it can call a ButtonPressed event in the door, passing in its ButtonID, which the door uses to set one of its boolean to true. then you can loop through all the booleans, checking if they are false, and if none are, open the door.

instead of having the buttons and doors directly communicate, i made a blueprint interface, called iDoorLock, and i made the door actor implement that interface in its class settings. this interface has functions for BtnPressed and SubscribeBtn. this way, you can have many other actors that are activated by buttons, without them inheriting from your door actor.

Thanks for the reply,
I’m going to study your blueprints when I get home. Adding another function to handle these states serms to make a lot of sense now that you described it.

Thanks a lot for the clear answer. It’ll probably take me some time to really experiment and understand it but this helps a lot.

here is a simpler version, using just 1 actor and recursion. in this example, buttons can trigger other buttons, doors and locks can be child classes of buttons, and you can make child classes that override PlayUnlockAnim, to make different animations play. no interfaces required.

This is awesome, thanks a lot for this info! really helpful!

Hey again, so I’ve finally spent a bunch of time trying to wrap my head around this and I think I finally start to get somewhere, but I’m not really sure what you were doing with the GET nodes and the lock variable (what type would that be)?

Would it be possible to see your component/my blueprints window set up as well?

Apologies for the really newbie questions, I’m learning a lot from trying to copy and the pick apart each section to slowly start understanding. Thanks for all the help again!

inside Btn blueprint’s event graph, make a variable of type Btn, this is a reference to another button, (whose animation will be played after this Btn’s animation finishes), you can name it whatever you want, i decided to name it lock. drag that Btn reference variable into the event graph, and choose Get. then you can right click on that and convert it to a Validated Get.

Thanks again for your reply. I managed to get it set up like you have it now, but I’m not sure I’m getting it really.
You’ve already helped me a bunch here and I really appreciate it so I totally understand if you don’t really have time to help out a complete noob any more! I’m a little confused as to how I’d connect this whole thing with my door (which is another blueprint) in my map, would I just have a variable of my Door class that I link in the PlayUnlockAnim (all I manage to get is that it opens up right away after I step on one button atm) - Can I even place a few instances of this button blueprint around in the level or is that not really how this is supposed to be set up? I’m just confused as to how I’d target the door and have it count that I used all the buttons before it opens.

I’ve tried to really pick this blueprint apart but I think I’m too novice really to grasp all of what is going on at the moment, I’m trying to put in an hour or so every day now to slowly get a bit more of an understanding of this following really basic tutorials as well.

Ops, gave it another shot and I think I FINALLY start to get it. I used your first example and it seems to work fine now! Somehow I found that one easier to understand, but now that I start getting what everything does I’m sure the second example is a better set up so I’m going to take some more attempts on that one too.

My first attempts I hadn’t created the SubscribeBtn correctly. I had just manually created a new function in my door blueprint after inheriting the interface blueprint so I basically didn’t use the inherited interface function…

Anyhow thank you so much for the help with this, I finally feel like this is a tiny step forward for me starting to understand anything about this :slight_smile: