- Home /
Sound Timing
Hey, does anybody know how to make it so it plays a sound once something like MouseEnter happens and then have it wait until it is able to have the sound played again? so lets say you mouse over the object, and it plays the sound. but, the sound cant be played again until after 20 seconds even if you mouse over it.
Comment
Best Answer
Answer by Seth-Bergman · Jul 24, 2012 at 12:57 AM
Just use a boolean to regulate it:
var canPlayAudio = true;
function OnMouseOver(){
if(canPlayAudio)
PlaySound();
}
function PlaySound(){
canPlayAudio = false;
audio.Play();
yield WaitForSeconds (20);
canPlayAudio = true;
}