Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Audio Sound overlapping itself?

Discussion in 'Audio & Video' started by Denisowator, Jun 9, 2017.

  1. Denisowator

    Denisowator

    Joined:
    Apr 22, 2014
    Posts:
    918
    Simple setup, weird problem.

    I have a sound I want to loop until a condition returns false. But when it plays, it sounds like it's playing a thousand times at once, and it just sounds like a swamp of bees instead of the actual sound. In the code I even have it set to "PlayOneShot", and I don't have "Loop" checked in the Audio Source. And it does look regardless (which is what i want), but again, it sounds like the clip plays itself a thousand times.

    Imagine if you pressed something on the keyboard, and you got that Windows error sound, and then you held that button down. it's pretty much like that.

    Any ideas what's wrong?
     
    Last edited: Jun 9, 2017
  2. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,304
    99% sure that your code is wrong.
    You're not setting flags or checking conditions properly.
    That results in you playing a new instance of the audio every frame as opposed to once
     
    Denisowator likes this.
  3. Denisowator

    Denisowator

    Joined:
    Apr 22, 2014
    Posts:
    918
    Thanks, fixed it. :)
     
  4. yashwanthd1998

    yashwanthd1998

    Joined:
    Sep 17, 2019
    Posts:
    7
  5. doarp

    doarp

    Joined:
    Sep 24, 2019
    Posts:
    147
    Probably removed PlayOneShot() from being fired on every Update() or something like that.
     
    yashwanthd1998 likes this.