extends Node var played_takeoff: bool = false var falling: bool = false var measure = 0.0 func jump(): var phys = $"../OnFootPhysics" var on_floor = $"../OnFootPhysics/Floor".is_on_floor var jump_intent = $"../MovementInput".jump_intent measure = min(measure, phys.velocity.y) print(measure) if jump_intent and not on_floor and not played_takeoff: $Jump.play() played_takeoff = true if phys.just_landed: $Jump.stop() played_takeoff = false if phys.just_landed_medium and not $CameraAnimation.is_playing(): $CameraAnimation.play("jump_landing") var landing_playing = $JumpLanding.playing or $JumpLandingHardCrunch.playing or $JumpLandingHardOuch.playing if not landing_playing: if not phys.just_landed_terminally: $JumpLanding.play() else: $JumpLandingHardCrunch.play() $JumpLandingHardOuch.play() if not on_floor and phys.is_falling_velocity_terminal() and not $FallingSound.playing: $FallingSound.play() $FallingSound.pitch_scale = rand_range(0.8, 1.2) elif on_floor: $FallingSound.stop() func footsteps(): var on_floor = $"../OnFootPhysics/Floor".is_on_floor var velocity = $"../MovementInput".input_xz if not on_floor or velocity.length() == 0: $Footsteps.stop() return if $Footsteps/Timer.time_left > 0.0: return $Footsteps.pitch_scale = rand_range(0.9, 1.1) $Footsteps.play() var is_sprinting = $"../MovementInput".sprinting if is_sprinting: $Footsteps/Timer.start(0.3) else: $Footsteps/Timer.start(0.5) func _process(_delta): if $"..".is_on_foot(): jump() footsteps()