[SOLVED] PlayOneShot Loop Possible?

Hi there,

Is it possible to use PlayOneShot to loop a sound x amount of times?

Sort of Like this:

var playHowManyTimes : Number;
playHowManyTimes = 4;

audio.PlayOneShot(sfx1,playHowManyTimes);

You could use InvokeRepeating like this (untested):

private var playHowManyTimes : int;
private var gapBetweenEachTime : int = 2;
 
function Start () {
    playHowManyTimes  = 4;
    InvokeRepeating("PlayMyAudio", 0, gapBetweenEachTime);
}
 
function PlayMyAudio() {
    audio.PlayOneShot(sfx1);
    playHowManyTimes -= 1;

    if (playHowManyTimes == 0) {
      CancelInvoke("PlayMyAudio");
    }
}