feat: adds a cd to the jump to prevent spam jumping up a slope

This commit is contained in:
DottsGit
2026-06-05 00:54:19 -04:00
parent 9f3264170e
commit 2c35f5074a
7 changed files with 23 additions and 7 deletions
+4 -2
View File
@@ -65,7 +65,7 @@ func update(delta: float) -> void:
machine.current_jump_count = 0
# Bunny hop: if jump was buffered or pressed on landing frame
if machine.input_jump_pressed or machine.jump_buffer_time > 0.0:
if (machine.input_jump_pressed or machine.jump_buffer_time > 0.0) and machine.jump_cooldown_timer <= 0.0:
var land_speed := Vector3(player.velocity.x, 0.0, player.velocity.z).length()
var bhop_speed := maxf(land_speed, minf(land_speed + params.bunny_hop_speed_gain, params.bunny_hop_speed_cap))
# Maintain horizontal direction, boost speed
@@ -81,6 +81,7 @@ func update(delta: float) -> void:
machine.on_ground = false
machine.jump_buffer_time = 0.0
machine.register_chain_mechanic("bunny_hop")
machine.jump_cooldown_timer = params.jump_cooldown
if player.jump_player:
player.jump_player.play()
# Stay in air state
@@ -90,8 +91,9 @@ func update(delta: float) -> void:
return
# ── Double Jump ───────────────────────────────────────────────────────
if machine.input_jump_just_pressed and machine.current_jump_count < params.double_jump_max_count:
if machine.input_jump_just_pressed and machine.current_jump_count < params.double_jump_max_count and machine.jump_cooldown_timer <= 0.0:
player.velocity.y = params.double_jump_velocity
machine.jump_cooldown_timer = params.jump_cooldown
machine.current_jump_count += 1
machine.register_chain_mechanic("double_jump")
if player.double_jump_player:
+4 -2
View File
@@ -28,24 +28,26 @@ func update(delta: float) -> void:
var vel: Vector3 = player.velocity
# ── Jump (coyote time + jump buffer) ──────────────────────────────────
if machine.input_jump_just_pressed and machine.coyote_timer > 0.0:
if machine.input_jump_just_pressed and machine.coyote_timer > 0.0 and machine.jump_cooldown_timer <= 0.0:
player.velocity.y = params.jump_velocity
machine.current_jump_count = 1
machine.on_ground = false
machine.coyote_timer = 0.0
machine.register_chain_mechanic("jump")
machine.jump_cooldown_timer = params.jump_cooldown
if player.jump_player:
player.jump_player.play()
machine.switch_to("air")
return
# Jump buffer: player pressed jump just before landing
if machine.on_ground and machine.jump_buffer_time > 0.0:
if machine.on_ground and machine.jump_buffer_time > 0.0 and machine.jump_cooldown_timer <= 0.0:
player.velocity.y = params.jump_velocity
machine.current_jump_count = 1
machine.on_ground = false
machine.jump_buffer_time = 0.0
machine.register_chain_mechanic("jump")
machine.jump_cooldown_timer = params.jump_cooldown
if player.jump_player:
player.jump_player.play()
machine.switch_to("air")
+2 -1
View File
@@ -99,7 +99,7 @@ func update(delta: float) -> void:
return
# Jump out of slide
if machine.input_jump_just_pressed:
if machine.input_jump_just_pressed and machine.jump_cooldown_timer <= 0.0:
player.velocity.y = params.jump_velocity
var hvel := Vector3(player.velocity.x, 0.0, player.velocity.z)
if hvel.length_squared() > 0.01:
@@ -109,6 +109,7 @@ func update(delta: float) -> void:
player.velocity.x = dir.x * jump_speed
player.velocity.z = dir.z * jump_speed
machine.current_jump_count = 1
machine.jump_cooldown_timer = params.jump_cooldown
machine.on_ground = false
machine.register_chain_mechanic("slide_jump")
machine.switch_to("air")
+3 -1
View File
@@ -48,12 +48,14 @@ func update(delta: float) -> void:
return
# ── Jump off wall ─────────────────────────────────────────────────────
if machine.input_jump_just_pressed:
if machine.input_jump_just_pressed and machine.jump_cooldown_timer <= 0.0:
var push_dir := machine.wall_normal * params.wall_run_jump_off_normal
player.velocity = Vector3(push_dir.x, params.jump_velocity, push_dir.z)
machine.wall_normal = Vector3.ZERO
machine.wall_side = 0.0
machine.wall_cooldown_timer = 0.3
machine.register_chain_mechanic("wall_cling_jump")
machine.jump_cooldown_timer = params.jump_cooldown
machine.switch_to("air")
return
+2 -1
View File
@@ -98,7 +98,7 @@ func update(delta: float) -> void:
vel -= machine.wall_normal * 2.0
# ── Wall jump ─────────────────────────────────────────────────────────
if machine.input_jump_just_pressed:
if machine.input_jump_just_pressed and machine.jump_cooldown_timer <= 0.0:
# Base jump off velocity on current preserved momentum
var jump_vel: Vector3 = _current_tangent * _run_speed
@@ -114,6 +114,7 @@ func update(delta: float) -> void:
machine.wall_side = 0.0
machine.wall_cooldown_timer = 0.3
machine.register_chain_mechanic("wall_jump")
machine.jump_cooldown_timer = params.jump_cooldown
machine.switch_to("air")
return