Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by cmpgk1024 · Aug 08, 2013 at 05:06 PM · networkingaudioaudiosourceaudiolistener

Audio listeners in multiplayer game

I'm working on adding audio to my multiplayer game. There is an Audio Listener attached to the player prefab I instantiate for each new player. It works with only one player connected, but with more than one player connected Unity says there are too many audio listeners in the scene. I tried adding
if(!networkView.isMine){ enabled = false; } to the script, but that didn't work.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by cmpgk1024 · Aug 08, 2013 at 07:32 PM

I got it working by modifying my script that I used to disable the camera and disabling the audio listener in it. Here's the code: #pragma strict public var cam:Camera; public var ears:GameObject; function Start () { if(networkView.isMine){ cam.active = true; ears.GetComponent(AudioListener).enabled = true; } else{ cam.active = false; ears.GetComponent(AudioListener).enabled = false; GetComponent(MouseLook).enabled = false; } }

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 Seizure · Aug 08, 2013 at 05:31 PM

Did you add the script and attach to the camera or is it on another player. Also try

 if(!camera.networkView.isMine){ Camera.main.camera.enabled = false; }
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 VolureDarkAngel · Aug 08, 2013 at 05:31 PM

the audio listener is where the current player hears things (their ears), each player would have their own audio listener, however hearing audio from another persons ears does not make sense.

Therefore only the active player should have an audio listener, and the other players should have their own ears.

Mixing the audio for split screen is beyond my expertise, so you would have to research that.

here is a link to a unity answer dealing with Split screen and Multiple audio listeners, in case this is your scenario.

http://answers.unity3d.com/questions/289325/how-to-have-two-audio-listenerssplitscreen.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 cmpgk1024 · Aug 08, 2013 at 05:38 PM 0
Share

This isn't split screen - it's played on two different computers so mixing won't be an issue. I just have to disable any ears that are not the local player's.

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

16 People are following this question.

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

Related Questions

Audio not playing well on AudioListener move 1 Answer

How do i stream music from a server? 0 Answers

Real time audio source on audio listener.... 0 Answers

Audio: -3db automatic attenuation on any audio playing? 0 Answers

GetSpectrumData or equivalent in non-realtime mode? 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