How to get audio to play after the first sfx end?

Godot Version

4.2

Question

I’m trying to get the second slash sfx to play. the animations work fine. animation attack2 start after the first animation but the sound doesn’t work.

func attack():
	if isDead: return
	
	animations.play("attackRight")
	$swordSlash1.play()
	if atk2:
		animations.queue("attack2")
		$swordSlash2.play()

I think the issue is that calling play on swordSlash2 will play it immediately, it doesn’t queue it after the first sound. You have to call play when the second animation starts, but I don’t know how it’s normally done…

1 Like

Thank Monday, I just solved it.

func _on_animation_player_animation_finished(anim_name):
	if anim_name == "die":
		get_tree().change_scene_to_file("res://scenes/gameOver.tscn")
	if anim_name == "attackRight" and atk2:
		animations.play("attack2")
		$swordSlash2.play()
1 Like

You can also call functions from an animation track. So, once attack2 is active, it would trigger the sound effect.