leg jump swap ani fix

This commit is contained in:
Nicholas Butzke
2026-08-10 12:57:41 -04:00
parent 0ce626ad42
commit bb34764d59
3 changed files with 70 additions and 19 deletions
+34 -19
View File
@@ -73,25 +73,7 @@ func update(delta: float) -> void:
machine.notify_landed(fall_speed)
# Bunny hop: if jump was buffered or pressed on landing frame
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
var hdir := Vector3(player.velocity.x, 0.0, player.velocity.z)
if hdir.length_squared() > 0.01:
hdir = hdir.normalized()
else:
hdir = machine.wish_dir_world
player.velocity.x = hdir.x * bhop_speed
player.velocity.z = hdir.z * bhop_speed
player.velocity.y = params.jump_velocity * params.bunny_hop_impulse
machine.current_jump_count = 1
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()
if _try_bunny_hop():
# Stay in air state
return
@@ -109,6 +91,7 @@ func update(delta: float) -> void:
player.double_jump_player.play()
return
# ── Wall interaction (Run, Climb, Vault) ──────────────────────────────
if machine.input_dir.length() > 0.1 and machine.input_dir.y <= 0.0 and machine.wall_cooldown_timer <= 0.0:
var fwd_wall = machine.detect_wall_forward()
@@ -143,3 +126,35 @@ func update(delta: float) -> void:
if machine.input_dash and machine.can_dash():
machine.switch_to("dash")
return
func _try_bunny_hop() -> bool:
# Held jump is intentionally accepted here so landing can immediately start
# the next hop without spending a frame in Ground. It is still a distinct
# takeoff and must emit the same event as every other grounded jump; the
# player model uses that event to alternate its complete airborne pose.
if not (machine.input_jump_pressed or machine.jump_buffer_time > 0.0) \
or machine.jump_cooldown_timer > 0.0:
return false
var player := machine.player
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.
var hdir := Vector3(player.velocity.x, 0.0, player.velocity.z)
if hdir.length_squared() > 0.01:
hdir = hdir.normalized()
else:
hdir = machine.wish_dir_world
player.velocity.x = hdir.x * bhop_speed
player.velocity.z = hdir.z * bhop_speed
player.velocity.y = params.jump_velocity * params.bunny_hop_impulse
machine.current_jump_count = 1
machine.on_ground = false
machine.jump_buffer_time = 0.0
machine.register_chain_mechanic("bunny_hop")
machine.jump_cooldown_timer = params.jump_cooldown
machine.movement_event.emit("jump", {"kind": "bunny_hop"})
if player.jump_player:
player.jump_player.play()
return true
+1
View File
@@ -63,6 +63,7 @@ func update(delta: float) -> void:
player.velocity = vel
machine.jump_cooldown_timer = params.jump_cooldown
machine.register_chain_mechanic("grapple_jump")
machine.movement_event.emit("jump", {"kind": "grapple_jump"})
machine.switch_to("air")
if player.jump_player:
player.jump_player.play()