#Footstep audio keeps repeating even when not moving.

4 messages · Page 1 of 1 (latest)

twin basin
#

`` if is_on_floor() && input_dir != Vector2.ZERO:
head_bobbing_vector.y = sin(head_bobbing_index)
head_bobbing_vector.x = sin(head_bobbing_index/2)+0.5

    eyes.position.y = lerp(eyes.position.y,head_bobbing_vector.y*(head_bobbing_current_intensity/2.0),delta*lerp_speed)
    eyes.position.x = lerp(eyes.position.x,head_bobbing_vector.x*head_bobbing_current_intensity,delta*lerp_speed)
    
else:
    eyes.position.y = lerp(eyes.position.y,0.0,delta*lerp_speed)
    eyes.position.x = lerp(eyes.position.x,0.0,delta*lerp_speed)


if not is_on_floor():
    velocity.y -= gravity * delta




direction = lerp(direction,(transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized(),delta*lerp_speed)

if direction:
    velocity.x = direction.x * current_speed
    velocity.z = direction.z * current_speed
else:
    velocity.x = move_toward(velocity.x, 0, current_speed)
    velocity.z = move_toward(velocity.z, 0, current_speed)

move_and_slide()

func _play_footstep_audio():
footstepoutside.pitch_scale = randf_range(.8, 1.2)
footstepoutside.play()
``

#

The animation "walk" has a call function which executes the function _play_footstep_audio. for some reason the audio just keeps playing even when I¨m not moving. How can I fix this?

twin basin
#

I´ve tried debugging using some prints to check if it recognizes if the sound has stopped playing. It knows when to play the sound, but the sound never stops

#

solved using chatgpt lol