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 looMeenin · Jul 16, 2014 at 12:19 AM · c#audiosource

How to mute specific audio sources?

How do I access the audio source of a specific object?

For example if I have a Bob object that wants to mute the audio source of a Steve object while continuing to play Bob objects audio source.

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
3
Best Answer

Answer by robertbu · Jul 16, 2014 at 12:39 AM

If your 'Steve' object has a unique name or a unique tag, you can do the following:

 GameObject.Find("Steve").audio.mute = true;

Or with a unique tag:

 GameObject.FindWithTag("Steve").audio.mute = true;



 
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 antoine42 · May 07, 2016 at 07:54 PM 0
Share

GameObject.audio has been deprecated. here is a solution that works now: http://stackoverflow.com/questions/24770249/how-can-i-mute-specific-audio-sources-in-unity3d

avatar image
2

Answer by rutter · Jul 16, 2014 at 12:41 AM

Given an AudioSource, you can stop it, pause it, or mute it.

To do that, you need to know which AudioSource you're targeting. The simplest thing is usually to show a variable in the inspector, so that you can set it by hand.

You can also use GameObject.Find or FindWithTag and GetComponent to find the AudioSource.

This is a lot of reading, but understanding how to find other objects in the scene is crucial to developing games in Unity.

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 IsaiahKelly · May 07, 2016 at 08:56 PM

The most flexible and powerful way to do this would be with an audio mixer.

  1. Create an audio mixer asset in your project.

  2. Add two groups to the audio mixer named "Bob" and "Steve".

  3. Assign audio mixer group "bob" to the output field of the audio source for Bob.

  4. Assign audio mixer group "Steve" to the output field of the audio source for Steve.


Now you can do all sorts of really advanced things through the audio mixer. Like decreasing the audio level of everything except Bob. This is a technique known as "audio ducking" and sounds exactly like what you want. Check out the official Audio Mixer and Audio Mixer Groups Tutorial to learn more.

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

25 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Problems with Audio Sources 1 Answer

Distribute terrain in zones 3 Answers

How to destory gameObject without destroying the audio source attached to it? 2 Answers

Disable the GUI when the character moving 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