Audio Listeners?

Hey guys,

In my error console, it says that I have 3 Audio Listeners, and I have no idea what on earth this means.

It says to ensure that there is always only one in the scene…?
I’m sure you know what I’m talking about…

Can someone please tell me how to fix this…

thanks

-Grady

This means you have more then one component in your scene which is responsible for receiving sounds played within the scene.

You might have a few cameras which by default come with an AudioListener component.

You should make sure only one of them is active at a time, so if you switch cameras disable the component (or the whole gameObject) before switching to a new camera and enable the one on the switched to camera.

You might also just keep 1 AudioListener in advance in your scene on a whole different gameObject and remove the rest.

To find all your AudioListener components in your scene go to the hierarchy window’s search field, click the little arrow to the left of it, select “Type”, and then write in the serah box: “Audiolistener”. Now your search will show you all game objects that have AudioListeners on them.
Don’t forget to select “ALL” again in the search box after you are done…

I only have one camera, Iv checked all 5 of the game obj in the scene, and cant find the other audio listener. I think its a bug. I was just working with the GUI on a new scene, when out of nowhere the error popped up for a 2nd audio listener. It would be nice if there was a way to search for it.

Audio Listeners is the ears of your player and is found on each camera. You probably have three cameras, the trick is to disable each camera and corresponding Audio Listener except the one you want to use when you switch between them.

I whipped up a script for you which is ready to go, just attach it to your main camera (or any other object which is enabled for the whole scene):

var cameras : Camera[]; //Attach your cameras in the Inspector to this variable array
private var currentCamera : int = 0;

function Start () {
	switchCameras(false);
}

function Update () {
	//Switch camera when user press "C"
	if (Input.GetKeyDown(KeyCode.C)) {
		switchCameras(true);
	}
}

//The function either resets the cameras or switch
function switchCameras (switchCam : boolean) {
	if(currentCamera+1<cameras.Length && switchCam) {
		currentCamera++;
	} else {
		currentCamera = 0;
	}
	for (camera in cameras) {
		camera.enabled = false;
		camera.GetComponent(AudioListener).enabled = false;
	}
	cameras[currentCamera].enabled = true;
	cameras[currentCamera].GetComponent(AudioListener).enabled = true;
}