Im making a split screen multiplayer game, like you all know you cant have more than one listener on Unity, so I had this idea of taking the viewport position to screen coordinates and then add those to the audio listener position. It kind of works but there are several problems, its really really slow, the game is for console and this really drops down the fame rate a lot, and also im pretty sure there are better and cleaner ways of doing this.
Please help me make this better:
“AudioMan” is the object containing the Audio Listener
foreach (Camera Cam in Cameras){
Vector3 ViewPortPos = Cam.WorldToViewportPoint(gameObject.transform.position);
Vector3 ScreenPositon = Cam.ViewportToScreenPoint(ViewPortPos);
Vector3 SoundPostion = AudioMan.transform.position;
SoundPostion += new Vector3 (ScreenPositon.x*0.05f,0,ScreenPositon.y*0.05f);
AudioSource.PlayClipAtPoint(AudioManager.Instance.Explosion, SoundPostion);
}
Thanks in advance.