then why does this work for me? (room_speed also equals 60 for me)
i use this code, and it video proof
Code:
if (canattack == true and distance_to_object(oPlayer) <=400){
canattack = false;
alarm [1] = room_speed;
}
\
UPD: I created another object and it doesn’t work with alarm until I write "if alarm <= 0 {}" now I'm confused why it works for me, maybe because it somehow manages to reset, I don’t understand
Code:
if alarm [1]<=0
alarm [1] = room_speed;
In the code above you have it enclosed in
if checks - which means it only runs when the
if is true.
In the above cases that will be when canattack is true and the distance to oPlayer is <= 400 (for the first one), or when the alarm has fired and is <= 0 (in your updated edit).
In your original code that I replied you have it in a Step Event with no checks so it runs every step no matter what. This means that it will never count down as it will be set to 60 every step.
Be aware that the alarm also won't count down and will be getting reset every step when
canattack is true and the distance is less than 400 as well, because every time the if check evaluates to true the code within will be run - setting the alarm to room_speed.