I was wondering if anyone knew how to start playing audio, then loop it. What I have so far is just a PlayOneShot, but I’m not familiar with how I would go about writing a script that checks to see if the audio has played in it’s entirety, then play the audio again and again in a loop.
Here’s the PlayOneShot script, using a Trigger to play the audio.
var Sound : AudioClip;
private var hasPlayed = false;
function OnTriggerEnter(){
if(!hasPlayed){
audio.PlayOneShot(Sound);
hasPlayed = true;
}
}
Does anyone know of a way to play the audio in a loop after the whole thing has played?
Using the “Loop” check box on the audio source won’t work obviously, since PlayOneShot cancels out that function.