Play 2 audios at the same time?

Hi,

I was trying to add audio for when my character is firing a gun shot, and the problem is that the audio clip I’m playing for the shot starts everytime I click the Fire button (mouse), but it als ENDS the last one, so when you shoot just a bit fast, it makes a horrible sound of audio stopping and beginning again.

In other questions I saw answers about clip.isPlaying, but I don’t want to delay the playing of my clip, I want it to sound at the same time (one before, one just after). Can’t they overlap?

I tried adding more AudioSource components and putting the same clip on them, and then looping (one shot for each of the AudioSources), but it was for no use…

Any ideas? Thanks a lot!

Won’t something like this work?

var shootSound : AudioClip;
var audioSources : AudioSource[];

private curAudioSource : int;

function Update (){
    if(weapon is shooting){
        curAudioSource++;

        if(curAudioSource > audioSources.length-1)
            curAudioSource = 0;

        audioSources[curAudioSource].PlayOneShot(shootSound);
    }
}

(Not tested code)

This should loop through all of the audioSources in ‘audioSources’ and play a new sound from a new audioSource everytime you are shooting, resulting in ‘overlapping’ audioclips. If you put 3 audioSources in the array, it should work smoothly.