0 votes

Uhhh how to make a "background music" play across a the entire scenes without it being paused and played again,

i set up an AudioStreamPlayer attached to the player scene so that the music would play every time a play a level, but as i transition to the next level it repeats itself, any examples on how to fix this?

asked Aug 10 in Projects by EnderCreeper1st (12 points)

2 Answers

0 votes

In Godot, changing scene is actually a shortcut for just removing a node and its children, and replacing it with another scene. Basically, it does this:

- root (Viewport)
    - YourCurrentScene <-- this node will be replaced
        - Player
            - AudioStreamPlayer <-- this one too because it's grandchild of the scene

If you want an AudioStreamPlayer to persist between two scenes, it needs to remain in the tree while you do the transition.
So an easy way to achieve this is to use a singleton node: https://docs.godotengine.org/en/3.0/getting_started/step_by_step/singletons_autoload.html

Then this will happen:

- root (Viewport)
    - YourCurrentScene <-- this node will be replaced
        - Player
    - AudioStreamPlayer <-- this one will remain
answered Aug 10 by Zylann (18,389 points)
0 votes

Try creating a global object which continues playing audio between scenes

answered Aug 10 by Moo (14 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 How to use this Q&A? before posting your first questions.