Audio doesn't play in AnimationPlayer

Godot Version

4.2

Question

Hey y’all, I’m trying to get an audio track to play at 0.6 seconds of my sprite animation. I’m using the AnimationPlayer to get this done. I’ve tried adding every track possible under the sun and nothing plays the audio in game. Every version I’ve tried to play audio, plays fine in the AnimationPlayer, but never in the game.

The sprite animation plays fine. Here’s a screenshot of everything I’ve tried. Obviously this is the end state, at my wits end. I did try each method individually first with no luck.

Is there a better way to play this audio at a specific point in the animation? Is there something I’m missing here? I tried a 2D audio node, a audiostream node, I tried key framing the Playing value to true, I’ve tried adding a new Audio track, I tried to autoplay to true at 0.6. Nothing works.

The track plays fine in game if I play it in script.

You could attach a script to your sprite or another node which ever works better for your project. In the script, you could create a custom function to play the track. I included a very basic example below and another one which plays after a specified amount of time. Then you could call the function in the AnimationPlayer.


@onready var track = $PathtoTrack

func playTrack():
	track.play()

func playTrackWithTimer(_duration:float):
	await get_tree().create_timer(_duration).timeout
	track.play()