I know you can only use one audio listener per scene but I have two player race cars that I need to have a “listener” attached to so that the AI car audio reacts properly depending on where they are in 3D space (passing the AI cars, etc). It works great in one player with the one listener, but is there any way to get the effect I’m looking for without adding another listener (which you obviously can’t do anyway)?
I hope I have made that clear enough… lol.
As you know, 2 audio listeners is not possible (though it should be).
The following answer is a hack, as it probably has several bugs, and a better solution probably exists.
I would have 1 static audio listener, and move audio sources around it. In your case, the audio listener would act as the ‘camera’. All audio sources require 2 versions: one for player 1 and one for player 2. They move around relative to how each player is moving. I know, that this is a lot of work. It requires 2 separate game objects containing an audio source and a script that moves it relatively to the player’s car, and the positions need to update EVERY FRAME.
The solution sucks to implement. I know. If it is really confusing, let me know and I shall update the answer with pictures.
I’m developing a Multi Audio Listener plugin based on Unity’s default audio components. The approach I took is similar to what rabbitfang described above, and it indeed turns out there’s quite a lot of boilerplate involved in making it work smoothly.
The plugin is currently available for testing (on demand) and will later be sold on the Asset Store. Contact me if you’re interested!
MultiAudio Listener: Split Screen Audio on the Unity Forums