1

In Godot 4.0.2 while making a platformer game, I'm using this code to create a coyote time effect, where moving off a platform still allows the character to jump for a short time while in midair. Using create_timer() with a float argument works as intended, but when I create a variable float and pass that as the argument, the timer runs out in much less time than expected.

Creating a timer with the following code and passing a float as the argument works correctly:

if is_on_floor() == false and can_jump == true and coyote_time == false:
    coyote_time = true
    await get_tree().create_timer(3.0).timeout
    can_jump = false
    coyote_time = false

However, if I create a variable for my argument as below, the timer is running out in much less than 3.0 seconds:

var coyote_time_timer = 3.0

if is_on_floor() == false and can_jump == true and coyote_time == false:
    coyote_time = true
    await get_tree().create_timer(coyote_time_timer).timeout
    can_jump = false
    coyote_time = false

I am new to programming, so there may be some fundamentals I'm misunderstanding here, but I don't know why this isn't working as expected.

Rafael
  • 1,281
  • 2
  • 10
  • 35

0 Answers0