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 Lawrence760 · Jul 02, 2015 at 08:57 PM · audiosoundaudiosourceaudioclip

Audio cuts out once a certain number of sounds are played

I am having trouble with my audio cutting out once a large number of sounds are played at once, when a lot of enemies are firing, and then resumes after a few seconds. I have a WorldController object that I have attatched a SoundController script to. This script takes some public AudioClip variables and plays them through functions. For example here is the most used one:

 //audioCenter is my AudioSource and FriendFire is the AudioClip
     public void playFriendFireSound(){
             audioCenter.PlayOneShot (FriendFire);
         }
 

This is called by the player whenever it fires a bullet.

I suspect its because an audio source can only handle so much audio but am not sure. Is this the problem and is there another way I can cleanly approach managing audio in my scene?

Thanks guys!

-Lawrence

Comment
Add comment · Show 3
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 triangle4studios · Mar 18, 2021 at 01:36 AM 0
Share

Bump. This is driving me nuts. So much so that after 2 years I am getting ready to change game engines.

avatar image Lawrence760 triangle4studios · Mar 19, 2021 at 04:17 AM 0
Share

Wow blast from the past. If I recall correctly the problem was that I was simply overloading the audio source with too many sounds playing at once. I had one enemy that was firing at a ridiculous speed (I think it was initially called every frame it was firing) and it was killing the audio. I think I just lowered the fire rate or just stopped it from playing a new sound clip every time it fired.

I know I still have the code and I'll try and find specifics for you.

avatar image Lawrence760 triangle4studios · Mar 24, 2021 at 10:33 PM 0
Share

So here we go! This was my solution. It turns out unity audio sources can get overloaded if too many sounds were played through them. My solution was to create multiple audio sources for specific sounds. That way there does not need to be overlap and every audio center doesn't need to be filled with every sound. This fixed the problem for me and even if an audio source is overwhelmed only that specific audio source will cut out (e.g. if I play too many shooting sounds my music still works even if the shooting sounds cut out) Here is my code:

 void Start () {
         audioCenter = GetComponent<AudioSource> (); // main sound source used for most things besides firing.
 
         friendFireAudioSource = gameObject.AddComponent<AudioSource> (); //creates a new sound controller for player fire
         friendFireAudioSource.clip = FriendFire;
 
 
         enemyFireAudioSource = gameObject.AddComponent<AudioSource> (); // creates new audio source for enemy fire
         enemyFireAudioSource.clip = EnemyFire;
     }
     

0 Replies

· Add your reply
  • Sort: 

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

22 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

Related Questions

What could make the audio loop? 2 Answers

Audio Manager 1 Answer

Is there a way to create a random Audiosource loop? 2 Answers

PlayOneShot returns false for isPlaying 5 Answers

Play sound from an array, not random, and only once 3 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