One-way doors (platform game)


#1

I want to do a one-way door that the player can pass throug from the right and can’t pass from the left. How can i do that?


#2

Have a hidden object (call it a trigger) wider than the door sprite, with it’s left edge just inside the door’s left edge. Link the trigger with the door image. When the player is in collision with the trigger, open the door that’s linked to the trigger. No collision and the door stays closed.

In the image below, the blue rectangle is the trigger, the brown thing is the door. The blue square is hidden at run time:

image

Alternatively, you could have 2 such triggers linked to the door - to the right one to open the door, and one to the left to close it.


#3

Thank you very much! <3


#4

You could also compare the X position of the Player to the X position if the Door. If it’s more, the door opens. If it’s less, the door doesn’t open.