0 votes

I have a AudioStreamPlayer2D with a song. Is there a way for it not to start over when the scene changes, but continue playing instead?

in Projects by (63 points)

Have you tried play in singleton?

3 Answers

+1 vote

I'm a godot newb, so hope someone else helps answer too, but just an idea: try creating a new thread and playing the song on it?

by (213 points)
+1 vote
by (213 points)

Thank you! But i aint very good at using the documentataion. I definetly understand how this works, I just don't know how to aply it to music.

Note: I dont need this song to be playing in ALL of the scenes

OKAY I figured it out! Problem is that... There is one scene with a diferent song... is there a way NOT to load the singletone during that scene??
UBDATE: The singletone only plays during the menu, where I dont need it playing! When I enter in another it just... Fades out after a few seconds!

0 votes

You want to keep the audio node alive so you have two options. First, the scene that had that AudioStreamPlayer2D needs to be on your main scene, this implies that you will never free or restart the scene. And the last option is that the scene that had the audio node needs to be a singleton using the autoload feature of Godot.

by (14 points)

Thank you! But is there any way NOT to load a singletone in particular scenes?

The singleton will be loaded at the beginning of your game, always. Try adding a script to the singleton with methods to control the music and you can pause it when is necessary

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 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 webmaster@godotengine.org with your username.