feat: adds a cd to the jump to prevent spam jumping up a slope
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user