- Home /
Multiple Audio listeners in multiplayer game?
My audio listener is attached to my camera, which is a child object of my Player Prefab. However, when another player joins the game, Unity makes a note at the bottom of the screen that multiple audio listeners are not supported, and the audio does not work correctly (sounds not playing, etc). How should I go about fixing this? (C#)
Answer by brendanperry05 · Jul 25, 2018 at 04:50 PM
You would have to move the audio listener onto its own gameobject that is not duplicated as new players join the game. There can only be one per scene so simply do not attach it in any way on your player prefab.
Edit:
It seems that each player in a multiplayer game has its own scene. Because of this, the technique that is used to combat the issue of multiple audio listeners is for each player to disable all other audio listeners upon spawning into the game.
Okay, but won't all player's hear the exact same audio? Like if one player is across the map from another and reloads his gun, the other player would hear it at the same volume as the person who reloaded?
Okay I understand the confusion. I think what you are interested in is 3D sound. Here is another answer that I believe would help you achieve what you're looking for: https://answers.unity.com/questions/247511/3d-sound-basics.html
Upon further research, this question seems to have already been asked. I think you should take a look: https://answers.unity.com/questions/448814/many-audio-listeners-to-multiplayer-how.html