Playing background music.

What is the quickest way to play background music but NOT AS A 3D sound. I want the sound level to stay constant throughout the game while my player roams the world freely.

Set up an audio source on the object with your audio listener. Have that source handle all the music for the game, and it should have a constant volume in all speakers.

You can also set up an audio source somewhere in the world with a rolloff factor of 0. You’ll run into it shifting from speaker to speaker depending on where it is relative to you, though. Could be cool if you attached it to something like an ingame radio or TV…

2 Likes

Can you just import the respective audio files with ‘3D Sound’ off?

Atatch a streio audio to the main camera, in the same position in the world as the camera. Easy.

Is there a reason that importing the audio file with ‘3D Sound’ set to ‘off’ wouldn’t be a viable solution? (There very well may be - just curious, really.)

Even if 3D Sound is off, that doesn’t stop it from getting quieter as it gets further away due to the rolloff factor. As a result, it wouldn’t help if the audio source wasn’t attached to the camera.

It is a solution, yes, but not one that’s perfect.

Are you sure about that? Have you actually tried it?

I just placed a looping sound in a scene with the first-person controller prefab, and the pan and volume of the sound changed as expected as I moved around. I then re-imported the clip with ‘3D Sound’ set to off. After that, the sound played at exactly the same volume regardless of where the listener was in the scene - no attenuation whatsoever. (I tried this in both 2.x and 3, and the results were the same.)

So again, are you sure that what you’re saying is correct?

After looking into this a bit more, I’m thinking your understanding of what the ‘3D Sound’ option does is likely incorrect.

As I mentioned, I tried this in both Unity 2.6 and Unity 3, and in each case setting ‘3D Sound’ to ‘off’ did in fact disable volume attenuation. What would the point of the ‘3D Sound’ option be if it didn’t disable volume attenuation? To disable pan and/or doppler only? That would seem kind of odd.

So again I’ll ask, have you actually tried this? Is what you posted above based on actual observation?

I know this thread is a bit old, but for future reference this is what i did.

  1. Make a camera (or use the main camera/ camera you already have setup)
  2. Add “Audio Listener” and “Audio Source” components to the camera
  3. On the Audio Source component add your music.

The camera can now be the object that can hear the music it plays. The camera will always be at the same spot so you wont have any weird volume issues with distance from the source.

1 Like

The correct way to play sound that does not relate to a world position is to do what Jesse Anders said multiple times above: Select the sound asset, disable the 3D Sound option and apply the changes.
Having the sound playing at the same position as the camera is just an unnecessary hack and adds complexity where it is not needed.

1 Like