you can't use WaitForSeconds in Update, because it's called every frame, but otherwise this should work, just remove that line..
but if you really want the pause, you can create a coroutine to call from Update:
var footsteps : AudioClip;
var waitTime = 0.5;
function Start(){
audio.clip = footsteps;
}
function Update () {
if(Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)
WaitFootsteps();
else
makeSound = false;
if(makeSound)
audio.Play();
}
function WaitFootsteps(){
if(!makeSound){
yield WaitForSeconds(waitTime);
makeSound=true;
}
}
this should pause before the FIRST step, I assume that's what you wanted.. If you're just trying to pause between EVERY step, just loop the clip and make it have a half-second pause in the actual audio clip, that would make more sense...
↧