- Home /
2 Audio listeners in scene, despite the fact 1 is disabled or destroyed
Hi,
Currently adding local coop to game. When one player is killed I disable its audio listener, then enable the other player's listener.
player.GetComponent<AudioListener>().enabled = false;
player2.GetComponent<AudioListener>().enabled = true;
Still getting the warning that "There are 2 audio listeners in the scene"
Also tried destroying the component, but to no avail. have confirmed in inspector that the AL component is disabled/destroyed.
Destroy(player.GetComponent<AudioListener>());
Before player 1 is killed, there are technicially 2 audiolisteners in the scene (one is disabled). Anyone know why this suddenly becomes a problem when I switch P1 off and P2 on?
Thanks!
Answer by Klarax · Feb 11, 2014 at 02:06 PM
i think you can only have 1 at all in the scene at any one time
http://forum.unity3d.com/threads/197189-1-scene-2-audio-listeners-How-to
Yeah, was aware of the 1 listener limit, but thought it applied to active. Could have added an audio listener that floats between players, but the issue seems to have resolved itself.
Answer by HalversonS · Mar 24, 2015 at 01:41 PM
Yes. You can have 2 audio listeners as long as only 1 is enabled.
There is a bug if you add multiple objects that have audio listeners on them. If you feel you get the message in error, search in your hierarchy for t:audiolistener. It will populate the list with all your objects that have an audio listener on them. If there is only 1 enabled you are receiving the message in error. If you attempt to delete all audio listeners you will receive compile errors but the console will have no information.
I found relaunching Unity did not help. I had to do a full system reboot.
Edit: Bug found in 4.6