How to make a button/door system?

I’m trying to make a puzzle game and I’m not sure how to go about making a button open a door (two different objects). I plan on having multiple of these per scene.

Hi DoubleA and welcome. Here’s a sliding door that is opened by the red button and automatically closes after three seconds. Have a play and see if it’s what you want! You will probably have some kind of change to the button to show that it’s pressed although I didn’t. The door has the Tween behaviour.

Sliding door

Thank you, that’s a huge help. Just wondering, would it be possible to use variables to make different sets of buttons and doors, so that activating one button doesn’t open every door object in the scene?

Would each door have its own button? If yes, then do you mean can each button open its door without having to have separate events for each one? Just one event?

Yeah, that’s what I mean. I feel like having a bunch of different events for each set would be unnecessarily tedious.

I had a go and got it working with doors that are aligned the same way. But if you had doors facing a different direction then you would need to have that as a different door object and a different opening position.

And also note that this is based on the button controlling the door that’s closest to it. I’ve also changed the position in the opening tween, it’s no longer an absolute value but relative to the current position.

Oh, and it also says Buttons instead of Button because I made a group of different buttons and then realised it was unnecessary but didn’t change it back.

Two sliding doors one event

That may work, I’ll try that out and see if anything comes up. Thank you again for your help!

Or I guess you could use the same door object for doors facing other directions. And you could have a condition if door is 0 degrees then tween in Y direction but if door is 90 degrees then tween in X direction.

I’m actually using sprite animations for my doors, so I don’t think the tween stuff will be necessary.

I got it working!!!

(player is jumping in both images because I have jump set to shift and i used win+shift+s to screenshot)


If you want to open a door that may not be the closest to the button, use an object variable as an id for the button and door objects. Use the same value on the button and the door it opens. Then when the button is touched/activated, select the door that has the same id as the button, and open it.

Trying that, and it doesn’t seem to work. I’ve made sure that each object’s variable matches up correctly, but it doesn’t work. My code may just be sloppy idk

EDIT: nevermind I figured out what was wrong, my dumbass somehow put like 3 different buttons in the same spot lmao it works fine now

That last event will never be actioned - it’s only ever reached if “e” key is pressed, and as this isn’t quantum physics, a key cannot be pressed and unpressed simultaneously.

Did it work before with that e key not pressed under the e key pressed condition?

I figured out what was wrong i was just being stupid lol