0

I have a mono .wav file that I'm trying to play as a PlayOneShot() AudioClip in my game using an AudioSource. The sound plays perfectly in the Unity editor but for some reason echos and leaves a lasting reverb in the game that never goes away. It's called using just a simple PlaySound function from here:

public static void PlaySound (string clip) {

    switch (clip) {
    case "death":
        audioSrc.PlayOneShot (deathSound);
        break;
    case "move":
        audioSrc.PlayOneShot (move);
        break;
    case "success":
        audioSrc.PlayOneShot (success);
        break;

    }


}

And this AudioSource handles all other sounds perfectly. I don't know what I can even try to change because I'm not messing with any AudioSource options to begin with. Does Unity2d not handle mono sounds well?

dulongj
  • 307
  • 2
  • 17

2 Answers2

1

I solved my own problem using information found here: https://answers.unity.com/questions/451895/distorted-audio-using-playoneshot.html

The problem was that the PlayOneShot was being called multiple times because the condition to play the noise was met for an extended period of time. To handle this I set a bool to false after it plays one time, and check to see if the bool is true before playing the sound to begin with.

dulongj
  • 307
  • 2
  • 17
0

You could do something like this:

public AudioClip[] otherSounds;
AudioSource audioSource;

void Start(){
    audioSource = GetComponent<AudioSource>();
}

void Update() {
    if(){
        audioSource.clip = otherSounds[Index];
    }
}
davidnatro
  • 63
  • 9