diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-11-14 12:41:08 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-11-14 12:41:08 +0200 |
| commit | c80c35213bb13ca7db939639d5a707f6944f8196 (patch) | |
| tree | 0559af4faa2beb00772bef49fcba7c37dd4bf1b2 /player.gd | |
| parent | 598c69ebc933cf3561eae0e8504f14b8bd6712ef (diff) | |
Add jump buffering
Diffstat (limited to 'player.gd')
| -rw-r--r-- | player.gd | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -8,6 +8,7 @@ extends CharacterBody2D var gravity = ProjectSettings.get_setting("physics/2d/default_gravity") var prev_dir: float = 0.0 +var jump_was_released: bool = true # coyote = 0 indicates on floor # coyote > 0 indicates frames since on floor @@ -44,11 +45,15 @@ func _physics_process(delta: float): else: coyote += 1 - var can_jump = coyote < coyote_max + var can_jump = coyote < coyote_max and jump_was_released if Input.is_action_pressed("jump") and can_jump: velocity.y = -jump_strength # Force coyote time to expire to forbid double jumps coyote = coyote_max + jump_was_released = false + + if not Input.is_action_pressed("jump"): + jump_was_released = true var direction: float if Input.is_action_pressed("move_left") and Input.is_action_pressed("move_right"): |
