• 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 /
  • Help Room /
avatar image
Question by Mihaeru · Mar 01, 2016 at 04:11 PM · audiocharactercontrolleraudiosourceoverlapsound effects

sound overlap, problems with character controller

I'm using the default first person controller in Unity 5 and now I'm getting problems in my game because when I'm wallkind it plays the "m_FootstepSounds" and I use the reloading action for the gun , that goes like this:

  if (Input.GetKey(KeyCode.R) && bullets<20 && ammo>0)
             {
                 GetComponent<AudioSource>().clip = reloadclip;
                 GetComponent<AudioSource>().Play();
                 Invoke("Reload", 1.0f);
                 reloading = true;
             }

I can't hear the reloading sound. I tried to search before asking but I couldn't solve the problem yet, I will appreciate any attempt to help me.

Comment

People who like this

0 Show 4
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 Nerevar · Mar 01, 2016 at 04:11 PM 1
Share

Hello, This might happen if your audio clip is a 3D sound and your audioSource is far from the audioListenner (listenner is by default on the mainCamera). Uncheck 3D sound option on your reload clip. Also it is safer to have a statement if(!audio.IsPlaying) before any`Play()` in a function that might be called several times per frames.

avatar image Le-Pampelmuse · Mar 01, 2016 at 05:14 PM 3
Share

As Nerewar stated, AudioSource.Play() is usually called only one frame. Otherwise it would start playing 30-60 (approx. depending on framerate) times within a second which can result in overlapping of 30-60 sounds.

I suggest you use Input.GetKeyDown, because you really only need to execute this code once.

avatar image Mihaeru Le-Pampelmuse · Mar 02, 2016 at 05:44 PM 0
Share

thanks for the last advice, I will use it. And talking about the Audio problem, I found a easy solution thanks to a friend of mine, it's not very elegant but works very well, I put one AudioSource for the reload and other for the shoot instead of the audioclips I call different audiosource variables, and now I can hear everything without overlap problem. Thanks a lot to both of you.

avatar image Le-Pampelmuse Mihaeru · Mar 02, 2016 at 07:59 PM 3
Share

Of course making a new AudioSource for different AudioClips is the solution that works immediately, but in the future you will find it most annoying to manage all the different sounds you might have. But you should figure it out in you own pace, nothing destroys the learning process more than you forcing yourself to learn things you dont need at the moment ;)

No problem, that's what the community is for. You could wait now if anyone else wants to give a more in-depth explanation or if you are satisfied, tell us to close this question.

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.

Update about the future of Unity Answers

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta later in June. Please note, we are aiming to set Unity Answers to read-only mode on the 31st of May in order to prepare for the final data migration.

For more information, please read our full announcement.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to make audio overlap itself? 1 Answer

Audio help 0 Answers

AudioSource.Play Not Playing audio but says it is 0 Answers

audio plays sometimes, then not others. 0 Answers

How can I get my sound array working here? 0 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