Godot Version
4.3
Question
I’ve been having problems with my walk sfx just playing the first part everytime it activates. I assume its because its in process but have no idea how to have it run seprately from process.
Here is my code:
func player_sounds(_delta):
if velocity.x != 0 and is_on_floor():
if !SoundManager.play_sound("sfx_dirt"):
SoundManager.play_sound("sfx_dirt")
You could loop your walking audio, start playing the sound when the player starts walking, .stop()
the sound when the player stops walking.
That doesn’t seem to work, I still have the problem of the walk sfx rapidly playing. Here is what I did. I didn’t loop cause that made the sound play forever once the player stood still.
func player_sounds(_delta):
if velocity.x != 0 and is_on_floor():
if sfx_dirt.playing == false:
sfx_dirt.play()
else:
sfx_dirt.stop()
Got it to work, heres my code.
func player_sounds(_delta):
if velocity.x != 0 and is_on_floor():
if ply == false:
ply = true
sfx_dirt.play()
if velocity.x == 0 or !is_on_floor():
ply = false
sfx_dirt.stop()