0 votes

Hi, I'm trying to convert a game from Godot 2.1 to 3.4 and I'm having an issue with the audio. Godot 2.1 had a SamplePlayer class that I'm trying to re-create using AudioStreamPlayers but so far I can't get any sounds to actually play.

I'm basically creating a stream player for each sound effect in a directory and creating a dictionary of all the sounds:

used_player = AudioStreamPlayer.new()
used_player.stream = load("res://assets/effects/%s" % file_name)
# store the player keyed by the name
effect_players[effect_name] = used_player

So later I can do something like this:

func play(name):
        print("Trying to play missing effect: %s" % name)

I've verified the loaded files are of class AudioStreamSample and printed the stream.data.size() to verify they're loaded but still nothing. Audio buses are all at default and all the files are .wav. Any ideas?

Godot version 3.4.4
in Engine by (126 points)

1 Answer

0 votes

Nvm... Apparently you have to add the stream players to the scene to actually be able to use them.


by (126 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.