I am having issues with getting an audio clip to loop after attaching a controlling script for key triggers. I’ve attempted to loop the clip by adding [audio.loop = true] before the playAudio and/or audio.PlayOneShot(AudioClip1) segment(s); however this does not loop the audio clip. Can someone point out what’s wrong here?
also: I have tried adding var loop : boolean = true; but this does not work either
var AudioClip1 : AudioClip;
var IsAudioPlaying : boolean = false;
function Update(){
if(Input.GetKey ("right ctrl") Input.GetKeyDown (KeyCode.Keypad8) || Input.GetKeyDown (KeyCode.Keypad2) || Input.GetKeyDown (KeyCode.Keypad4) || Input.GetKeyDown (KeyCode.Keypad6)){
audio.loop = true;
playAudio();
} else if (Input.GetKey ("right ctrl") Input.GetKeyUp (KeyCode.Keypad8) || Input.GetKeyUp (KeyCode.Keypad2) || Input.GetKeyUp (KeyCode.Keypad4) || Input.GetKeyUp (KeyCode.Keypad6)){
stopAudio();
}
}
function playAudio (){
IsAudioPlaying = true;
audio.loop = true;
audio.PlayOneShot(AudioClip1);
}
function stopAudio (){
IsAudioPlaying = false;
audio.Stop();
}