Hello there, I am working on a 2D platformer, and I wanted to add footsteps sound. Here is how I implemented it:
onready var footsteps = $AudioStreamPlayer
func _physics_process(delta):
die()
jump()
gravity()
handle_input()
walk_sound()
motion = move_and_slide(motion, Vector2.UP)
func walk_sound():
if is_on_floor() and not footsteps.is_playing() and motion.x != 0:
footsteps.play()
Only the very first part of the audio plays and keeps looping. I double checked that the audio is not set to auto_play. I did set it to loop as I am using a 5 seconds long audio, so if player walks more than 5 seconds it'll just loop. What am I doing wrong?
Any help is appreciated thanks!