auroraborealis
Member
Hey. It's me again. I'm trying to make doors for a top-down game and I keep encountering this problem where only one door that I interact with and open will actually open, meanwhile the other one does not work at all.
Once open, it will not close again despite being programmed to.
This has been annoying me for hours.
Here is the code I wrote for the doors:
What am I doing wrong? Any help is appreciated. Thanks!
Once open, it will not close again despite being programmed to.
This has been annoying me for hours.
Here is the code I wrote for the doors:
GML:
//Create Event
open = false;
Code:
//Step event
with (obj_doorHor)
{
if (distance_to_object(obj_player) <= 20) && (keyboard_check_pressed(ord('E'))) && (!open)
{
open = true;
sprite_index = spr_doorOpen;
}
}
with (obj_doorHor)
{
if (distance_to_object(obj_player) <= 20) && (keyboard_check_pressed(ord('E'))) && (open)
{
open = false;
sprite_index = spr_door;
}
}
Attachments
-
45.6 KB Views: 1
Last edited: