Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by milanow · Aug 18, 2015 at 04:17 AM · audiosoundaudiolistenersplit-screensplitscreen

In a split screen game, how to deliver different 3D sound?

Hey guys, so Unity3D does only support one audio listener in scene. But when developing a split screen game (like Rocket League), two different players may hear different sound since they are in different locations. But this explosion happens at the same time, same frame. Then how to make sure both players get the correct sound information (3D, so it's more about location)?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Deuce2008 · Oct 27, 2020 at 10:05 PM

So I like you am creating a split-screen game and found this question because I had the same problem. Now I know this is a REALLY REALLY old question but, I found a way to fix it, instead of two audio listeners, make an empty object and add a audio listener component to it. Next reset it's transform, then in your script that plays audio create a public Game Object like below:

  public GameObject audioSpot;
  public AudioClip Clip;
 
 void Update()
 {
       audioSpot.transform.position = transform.position;
       AudioSource.PlayClipAtPoint(Clip, audioSpot.transform.position);
 }


Then drag in the audio listener object and play the clip at its position.

Hope this helps!

Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Deuce2008 · Apr 09, 2021 at 07:35 PM 1
Share

If anybody finds this helpful please respond...

avatar image s4shrish Deuce2008 · Apr 11, 2021 at 03:17 PM 0
Share

Sure bro, this is pretty helpful.

Unfortunately, I don't feel like implementing any of the solutions RN. Will have to make full systems next time I am planning a split screen game.

avatar image Lockes_TheThief · Jun 09, 2021 at 03:17 PM 0
Share

Has this ended up working? I'm trying it myself but I'm not sure which clip plays audio... I made the empty game object and put an audio listener in it but that is as far as I've got.

avatar image Deuce2008 Lockes_TheThief · Jun 09, 2021 at 05:04 PM 1
Share

So say you have a gun, and want to make a noise when it fires, do this:

 //This is the var that your object with the audio listener will go in
 public GameObject audioSpot;

 //your Music file goes here
 public AudioClip GunClip;

 void Update()
 {
     //This checks if you left click.
     if(Input.GetButtonDown("Fire1"))
     {
         //This calls the Shoot() function.
         Shoot();
     }
 }

 void Shoot()
 {
     //This will move the Audio Listener to the gun's position.
     audioSpot.transform.position = transform.position;

     //This will play your clip at the Audio listener's position.
     AudioSource.PlayClipAtPoint(GunClip, audioSpot.transform.position);
 }

I hope this helps. If you still need help feel free to ask. (:

avatar image Lockes_TheThief Deuce2008 · Jun 09, 2021 at 06:01 PM 0
Share

Okay, thanks so far! I'm not the greatest coder so I'm a little stuck. Each item that makes a sound would need this separate bit of code added to it?

Show more comments
avatar image
1

Answer by getyour411 · Aug 18, 2015 at 04:18 AM

http://answers.unity3d.com/questions/23235/split-screen-game-audio-listeners.html

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image milanow · Aug 19, 2015 at 03:46 AM 0
Share

I have seen this before asking. But thanks.

avatar image
0

Answer by coderxx · Dec 17, 2015 at 11:03 AM

Updated Answer: http://forum.unity3d.com/threads/multiple-cameras-and-audio-listeners.117130/

 public Transform _AudioListener;
 public void SetCamera( int camNum )
 allCams[renderCam].enabled = false;
 allCams[ camNum ].enabled = true;       // enable the selected camera
 // attach audio listner to camera
 _AudioListener.parent = allCams[ camNum ].transform;
 // align audio listener to camera (do after parent)
 _AudioListener.localPosition = Vector3.zero;
 _AudioListener.localRotation = Quaternion.identity;
 renderCam = camNum;                         //  save the current camera index

Older answer: You need to add an audio listener to each camera. Then choose the audio-source for each camera according to your liking.

This camera would 'be on each user's Player Controller and should give you what you need.

Edit, sorry, just realized the issue with Unity multi-audio listeners. This has been a hugely requested feature and multiple audio listeners is an issue with Unity. So refer to the discussions below.

http://forum.unity3d.com/threads/multi-audio-split-screen-audio-plugin-beta.165694/ http://forum.unity3d.com/threads/multiple-cameras-and-audio-listeners.117130/

Also, here is a list of search on Unity answers. Any combination of these can help your particular issue.

http://answers.unity3d.com/search.html?f=&type=question&redirect=search%2Fsearch&sort=relevance&q=audio+listener+split+screen

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Max_Bol · Nov 18, 2016 at 08:10 PM

The ugly reality about splitscreen in Unity is that you can't use its native 3D sound system on each camera. The reason is that there's no priority system that runs outside of the Sound Listener system so if you had 2 Sound Listeners, the engine wouldn't know which one is "loudest" and if it were to play both, the sound would always play twice at different volume if the the "players" are close to each other. There's also the issues that Audio card on PC or console have a limited amount of channels. Using 2 Sound listeners would requires that both separate the available sound channels equally, making the game using 2x more sound channels (or dropping the capacity by half).

We're still waiting for a Audio Manager that could manage such a thing internally since as earlier as 2007.

So, to make a splitscreen that has 2 different camera, you got to create your own 3D sound system that manage such a things as the proximity + priority of each 3D based sounds.

First, you got to "unify" the sounds listener. This can be done in multiple ways, but the most important point that join them all : only 1 audio listener. Then you got to put a priority system as to how loud each sound should be based on each "players" position.

If I had to put it my own vision of one possibility, that would be to build an invisible "audio world". You create an "AudioWorld" empty game object which has the AudioListener component and whenever something can make a sound exists, you create an empty child to that game object that represent that something with the sound source component. An easy way of doing this is to create a script that can be placed on every "somethings that make a sound".

That script would or could :

1) Create the AudioWorld's child game object that represent the source of the sound.

2) Update the child game object transform based on distance between the players.

Note : This part can be done 3 ways. Either you compare the distance between each splitscreen players positions and the source of the sound and uses the closest (loudest) for the child transform relative position OR you make an average of both distance and put it in the middle. Both ways have their good and bad side. The closest method make the furthest player unable to know how far the sound was from or which way it was from while the average method makes both players unable to really guess the distance or actual direction. The last way is to generate 1 child in the AudioWorld for each player, but each with a slight variation on the axis based on how the screen is split and play both of them.

3) Make sure that whenever the "sound source" which dictate its AudioWorld child position is destroyed, that the said child gets destroyed first, otherwise you'll end up with a tons of useless gameobject with sound sources in the AudioWorld. Best bet is to manage the destruction of any gameobject through a function on each game object that manage the destruction instead of just calling in Destroy(GameObject). (Something like GameObject.GetComponent().StartDestroySequence(); which would include the StartDestroySequence() function that would know what has to be destroyed/removed from the scene. You could even fit the whole AudioWorld child instantiation system through that ObjectInstanceManage script if you wanted.)

Anyway, for anyone looking for a splitscreen audiolisters simulation, that's the general way of doing it with Unity. Yeah it's a pain in the butt but you got to think that they couldn't include it because, as I explained it, there's too many ways of handling it and, ultimately, there's no ultimate perfect way that will please everyone. (Like X Game would want it so that every sounds from every local player perspective and would have to be able to manage a slightly variation of each sound based on how the screen is split while Y game would want it for that it plays only once on the closest while Z game would want it to be average.)

Lastly, if you really don't want to manage all the sounds through each player perspective, you could just turn off the 3D sounds and play every sounds in 2D/Mono.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by DemonWhisper · May 02, 2019 at 09:06 PM

"The ugly reality about splitscreen in Unity is that you can't use its native 3D sound system on each camera. The reason is that there's no priority system that runs outside of the Sound Listener system so if you had 2 Sound Listeners, the engine wouldn't know which one is "loudest" and if it were to play both, the sound would always play twice at different volume if the the "players" are close to each other. "

However, Unity could easily provide a solution to this, simply implement a mixer that sits after the audio listeners in the signal chain and allow to add audiolisteners as audio channels to this mixer.

"There's also the issues that Audio card on PC or console have a limited amount of channels. Using 2 Sound listeners would requires that both separate the available sound channels equally, making the game using 2x more sound channels (or dropping the capacity by half)."

This is not true at all. This issue has absolutely zero to do with audio cards, it is not a hardware problem but solemnly a software issue within unity. Mixing together two audio channels is as easy as simply adding the audio-signals together, then 2 signals become 1 signal, you don't even need an audio card to do that a CPU is more that capable. The only thing you need an audio card for is for converting analog signals to digital in order to provide mic-input or for converting digital signals to analog for audio output. When you look at an audio card specification and it is specifying a certain number of audio channels that would be the number of physical inputs and physical outputs that the audio card provides, this usually comes down to a mic input a line input and a stereo output. Any stereo signal will always only have exactly 2 channels, left and right.

Some big external audio cards meant for professional audio production will provide more than this, so you could have a big external audio card with 8 input channels and 8 output channels, which would allow you to input 8 different signals for example from mics, guitars, synthesizers, drums, etc. to do a big recording, and you could send 8 different audio signals to 8 different audio outputs so that you could hook them up to different external effect processing units or different channels on an actual physical analog hardware mixer. It has nothing to do with the amount of audio signals that your computer can handle internally, any computer can virtually handle an infinite amount of audio signals.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I use Unity's Doppler effect with high velocity objects? 1 Answer

Max amount of simultaneous, hearable sounds? 1 Answer

Best way to play many audio clips at the same time? 0 Answers

Mute/Unmute not working with new sounds 2 Answers

Audio listener to mono then to left or right speaker? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges