Godot Version
4.2.2
Question
I’m trying to make an AudioStreamPlayer play a sound repeatedly with a slight delay between each sound. I have it set up so that it should theoretically pick a sound, play it, wait for it to finish, then repeat until it’s done it enough times. Instead it plays it seemingly every frame, with no clear regard for the timer.
Here’s the code I have right now:
if Globals.health > health_prev_frame:
for i in (Globals.health - health_prev_frame):
$AudioStreamPlayer.stream = load("res://sounds/Heal" + str((randi() % 3) + 1) + ".wav")
$AudioStreamPlayer.play()
#await $AudioStreamPlayer.finished
await get_tree().create_timer(($AudioStreamPlayer.stream.get_length())).timeout