+1 vote

Simple question, what is the best way to play a global stereo sound?
I always used SamplePlayers with sample libraries at the moment, but now I need something more "global"...

in Engine by (28,982 points)

1 Answer

0 votes
Best answer

You could create a scene that has the music node , and then make a singleton(autoload) of it.

Controlling it would be just a matter of calling its functions or variables from any other script of your game.

It would be loaded globally and you'd be able to play or pause songs that would play between scenes.

Have a look at godot's singleton page

EDIT:

Looks like your explanation was a little misleading for me, so now that I understood:

You should use "SamplePlayer" instead of SamplePlayer2D.
The main difference between the two is exactly this: SamplePlayer plays globaly on a scene, with no regards to the camera or viewport.
enter image description here

by (233 points)
selected by

I dont want to play a song/stream, but a sound that has no spatial position. The problem with SamplePlayer is they are affected by the camera, I don't want that. But I also don't require the sound to be streamed, because it's just a sound FX.

Then, you should use "SamplePlayer" instead of SamplePlayer2D.
The main difference between the two is exactly this: SamplePlayer plays globaly on a scene, with no regards to the camera or viewport.

Sorry, I wrote "SamplePlayer" but I meant "SamplePlayer2D" indeed. So I'll use SamplePlayer for global sounds now :)

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.