feat: implement ground movement state with integrated jumping, sliding, and stair-stepping logic
This commit is contained in:
@@ -70,20 +70,32 @@ func _process(delta: float) -> void:
|
||||
var sm = player.get_node_or_null("MovementStateMachine")
|
||||
var is_sliding = sm and sm.current_state == "slide"
|
||||
|
||||
var target_bob_y = 0.0
|
||||
var target_bob_x = 0.0
|
||||
|
||||
if player.is_on_floor() and hspeed > 1.0 and not is_sliding:
|
||||
_bob_timer += delta * params.head_bob_frequency * (hspeed / params.walk_speed)
|
||||
var bob_y := sin(_bob_timer) * params.head_bob_amplitude
|
||||
var bob_x := cos(_bob_timer * 0.5) * params.head_bob_amplitude * 0.5
|
||||
camera.position.y = lerp(camera.position.y, bob_y, 0.3)
|
||||
camera.position.x = lerp(camera.position.x, bob_x, 0.3)
|
||||
target_bob_y = sin(_bob_timer) * params.head_bob_amplitude
|
||||
target_bob_x = cos(_bob_timer * 0.5) * params.head_bob_amplitude * 0.5
|
||||
else:
|
||||
_bob_timer = 0.0
|
||||
camera.position.y = lerp(camera.position.y, 0.0, 0.15)
|
||||
camera.position.x = lerp(camera.position.x, 0.0, 0.15)
|
||||
|
||||
# Smooth the head bob (using 15.0 * delta for framerate independence, roughly equivalent to lerp 0.3 at 60fps)
|
||||
if not has_meta("smooth_bob_y"):
|
||||
set_meta("smooth_bob_y", 0.0)
|
||||
set_meta("smooth_bob_x", 0.0)
|
||||
|
||||
var sby = lerpf(get_meta("smooth_bob_y"), target_bob_y, 15.0 * delta)
|
||||
var sbx = lerpf(get_meta("smooth_bob_x"), target_bob_x, 15.0 * delta)
|
||||
set_meta("smooth_bob_y", sby)
|
||||
set_meta("smooth_bob_x", sbx)
|
||||
|
||||
# ── Step Smoothing ─────────────────────────────────────────────────────
|
||||
_step_offset_y = lerpf(_step_offset_y, 0.0, 15.0 * delta)
|
||||
camera.position.y += _step_offset_y
|
||||
|
||||
# Apply final absolute position
|
||||
camera.position.y = sby + _step_offset_y
|
||||
camera.position.x = sbx
|
||||
|
||||
# ── Wall-run tilt ─────────────────────────────────────────────────────
|
||||
_current_tilt = lerpf(_current_tilt, _target_tilt, 1.0 - exp(-params.wall_run_tilt_speed * delta))
|
||||
|
||||
Reference in New Issue
Block a user