Can I play sounds using the AnimationPlayer?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Fupicat

I’m making a 2D game, and I want to add step sounds to the walking animation. Can I do that with key-frames inside the animation tab, so that the sounds correspond to the animation? I tried to use the AudioStreamPlayer but it doesn’t seem to work at all.

As far I know, you can call functions in the animationplayer. Add a call function track and populate it with keys triggering a function that play the sound in certain periods.

Alex Pires | 2019-01-23 00:56

I never knew that! Gonna test this right now.

Fupicat | 2019-01-23 01:04

This worked very well! Thank you so much.

Fupicat | 2019-01-23 20:14

You’re welcome.
: )

Alex Pires | 2019-01-24 15:23

:bust_in_silhouette: Reply From: Dlean Jeans

Totally possible. I created an animation with text being typed out accompanied by keyboard sound.

  1. Create an AudioStreamPlayer and an AnimationPlayer.
  2. Click the AnimationPlayer to open the Animation tab
  3. Click + Add Track > Audio Playback Track
  4. Right-click on the track > Insert Key
  5. Click on the keyframe you’ve just created
  6. Load the sound file into the Stream property (That’s it!)
  7. You might want to save it as a .tres so you can drag-n-drop it onto the track
  8. Or you can just copy it

I don’t see “Audio Playback Track” anywhere in the Add Track menu.
enter image description here

Fupicat | 2019-01-23 13:36

It’s only available in Godot 3.1, I forgot.

Dlean Jeans | 2019-01-24 15:22

That’s OK, I’ve already found an answer. Thanks, anyway!

Fupicat | 2019-01-24 15:25