I want to add a little timer so there's a delay when warping between rooms so a sprite animation can play for the player, but for some reason my timer variable isn't working and I don't know what's wrong with it.
Here's the code, this is in a collision event between the player and warp object
timer = 17;
sprite_index = spr_playerenter;
image_speed = anim_speed;
state = "CANT_MOVE";
timer--;
if (timer <= 0) {
room_goto(other.targetRoom);
x = other.targetX;
y = other.targetY;
state = "IDLE";
}
With the timer, I made the variable and added timer--;
because that's what is needed to have the value decrease, right? And the rest is pretty simple, when the timer reaches 0, the player will be warped to the room stated as the variable at this x and y position.
The sprite animation did play, but I guess the timer isn't working because nothing stated in the timer happened at all.
Any help is appreciated, thanks!