SFX for AnimatedSprite2D Help

Godot 4.3

I have made all my sprites using an AnimatedSprite2D but I am now lacking understanding how to apply sfx like walking to the player.

elif object_in_hand  != null:
	animated_sprite.play("holding walking")
else:
	animated_sprite.play("walking")
        walking_sfx.play()

As in my code above this would be fine for say player jumping as that would just be a single play through of the sound, however, when walking it just sounds a mess. I think this is due to the fact its trying to play on each frame???

Do I need to approach this by making a func that controls the sfx with a signal maybe? How can I get the wlaking sfx to play smoothly?

Or

Am I best recreating my player animations in an animation player and applying sound this way and remove the need for code?

Cheers.

You can check if the player is playing before starting the sfx again.

elif object_in_hand  != null:
	animated_sprite.play("holding walking")
else:
	animated_sprite.play("walking")
	if not walking_sfx.playing:
	 	 walking_sfx.play()

Facepalmed over this. Thanks very much though!

1 Like