Sound far too quiet

A quick post in case anyone else runs into the same issues as I had with sound. I’m following the course in Unity 5.5 and there seem to be some peculiarities with the way Unity handles 2D sound. I was having major issues with my enemy explosion sounds being way way too quiet (practically inaudible) versus my player and enemy shot sounds. I have attached my shot sounds to the relevant game objects (EnemyShot and PlayerShot) with “Play On Awake” checked. This works fine in my game because the sounds are short and finish playing long before their containing shot objects reach the shredders I have set up at the top and bottom of the screen. I have my explosion sound attached to my enemy ships and that gets played using PlayClipAtPoint. The sound of the explosion was way too quiet. I first fixed this by playing the sound closer to the Audio Listener (attached to the main camera by default) using the following code:

AudioSource.PlayClipAtPoint(gameObject.GetComponent().clip,Camera.main.transform.position);

That worked but the sound was too loud. Altering the sound volume in the inspector didn’t alter the volume so I approached it in a different way. I amended the code by subtracting a Vector3 (0f,0f,2f) from the main camera position to place the sound a little further away from the audio listener. That worked but the whole thing felt like a bit of a kludge, so I did some more reading around the problem.

It turns out that the PlayClipAtPoint method has a third parameter that I didn’t know about:

public static void PlayClipAtPoint(AudioClip clip, Vector3 position, float volume = 1.0F);

So I amended my code as follows:

AudioSource.PlayClipAtPoint(gameObject.GetComponent().clip,transform.position,1f);

Lo and behold it works. Moral of the story: RTFM. :wink:

[Update: Whilst it’s louder than before, it’s still not quite loud enough. Looking at other methods of making it louder. Suspect I need to be looking at the sound ‘rolloff’. Sticking with the camera kludge for now]

1 Like

Worked out what the problem is. I paused the game during a test play just after PlayClipAtPoint spawned the player explosion sound. Clicking on the sound in the Scene view let me examine it in the inspector. It seems PlayClipAtPoint is automatically setting the Spacial Blend to 1 (i.e. 3D). I guess that makes sense given that you are asking to play the sound at a particular point in 3D space. It just means that the method can’t be used in games with 2D audio any more without experiencing major volume issues…

OK. Here’s my solution for this.

AudioSource.Play() plays 2D sound properly, keeping the spacial blend setting at 0. The problem is that I couldn’t use that on destruction of player or enemy ships as the gameobject is destroyed before the sound finishes playing. My solution was to create a “Sound Manager” object as follows:


This contains the two audio sources I want to play (enemy and player explosion sounds) and I added a Sound Manager script component as follows:

Then I can call the public PlaySound method in this script from any other gameobject. Here’s my code from the Enemy Contact script:

This works in the same way as calling the score method in the score keeper script to increment the score which was covered in earlier lectures. The whole thing plays 2D sounds as expected with appropriate volume levels not diminished by distance from listener to source.

You can also check the sound clip file in the inspector and if it is set to be a 3D sound, uncheck the box which turns it into a 2D sound. This will also fix the volume issue.

1 Like

I don’t see a setting for 3D sound for sound clips in Inspector.

Would have been nice to actually paste the code, rather than a screenshot.