Godot Version
Godot-4
Question
I’m making a 2D platformer, and implemented coyote time. Upon doing some research after the fact, I found that most people do this using timer nodes. I did not do this and was wondering if there were any benefits to using a timer rather than a variable that counts down every frame. Would it be worth changing to use a timer node instead?
In case it helps answer my question here is my coyote time implementation:
“Coyote time”
if wasOnFloor and not is_on_floor():
coyoteTimer = 6
if is_on_floor():
canJump = true
elif coyoteTimer > 0:
canJump = true
else:
canJump = false
wasOnFloor = is_on_floor()
if not is_on_floor():
coyoteTimer -= 1
“Handle jump”
if Input.is_action_pressed(“ui_up”) and canJump:
velocity.y = JUMP_VELOCITY
if Input.is_action_just_released(“ui_up”) and velocity.y < -200:
velocity.y = -200