[Solved] I can't figure out how it works and why my door doesn't work

The code works from top to bottom, if the animation is closed - it makes it open. That works fine.

The problem arises when you have another condition underneath it checking if it’s open. Your code checks if the door is closed, makes it open but it also sees that it is open and makes it closed.

What I usually do in these situations is make a boolean variable and when the E key is pressed, set it to true before the sub-events happen.
After the animation changed to open, change the boolean to false.
When you check if the door is open, add a condition to check if the boolean is true. This way it won’t just close immediately after opening.

1 Like

Thank you, but you could show me what it’s supposed to look like.

I really want to learn how to do this. I can’t get started with variables, although I realize that it is necessary.

Please show me how to do it on an example.

Change to key released and add trigger once to the sub events might work if you dont want to use boolean variable

until it still doesn’t work
I need a variable anyway, because I want to check for the key afterwards.

Please explain how to do this correctly

Have a boolean for the door called open

If open is false the animation is closed
If open is true the animation is open

If open is false and e is pressed set the boolean to true
If open is true and e is pressed set the boolean to false

Also you could have a global boolean for haskey…
if false you cannot interact with the door
If true you can interact with the door


I did what you said, but now the doors only open but don’t close.

Put the Trigger once on each condition


still doesn’t work. It opens, but it doesn’t close

Your second event is setting to true you need to change to false

Still doesn’t work closing. I think the conflict is exactly the same as it was before and everything should be done in one query. It’s just that I have never done it before, so I can’t figure out how to do it all in one query.

It should be like this, and the “door” variable is set to “false” by default.

You have to seperatw the events so

Boolean false is closed animation
Boolean true is open animation

Collision and e press sets boolean

This needs to be set in the variables of the “door” sprite.
I just can’t figure out where exactly it needs to be set.

I don’t understand, I think I added a logical variable “door” why the closing doesn’t work I don’t understand.


Have I done everything right?
If not, please tell me where the mistake is.
But so far it doesn’t work.

You’re running into the same issue. The actions of the first event are such that all the conditions will be met in the second event, so that then gets actioned too, and the animation never appears to change.

Try this instead. It uses a trigger once on the key press player-door collision and a boolean variable to track whether the door animation has been changed in this set of events:

1 Like



I have all the doors closed by default.
I did everything as you wrote, but the doors still won’t open or close.

Haha, my bad :man_facepalming:. That animation change action in the last event should be to “open”.

Teach me to rush a copy & paste.

1 Like

Hallelujah, thank you, it really works. How to add a key check ? I understand also through a variable ?

Yes, you’ll need to store if the player has a key in a variable, and then check that variable as part of the first event’s conditions.

1 Like