Im trying to have this script play the footstep sounds at a normal speed when the player is just walking but when sprinting the sounds are sped up, but this script doesn’t work and for some reason crashes Unity. Can someone help me out?
var footsteps : AudioClip;
var waitTime = 0.5;
var sprintwaitTime = 0.2;
function Start () {
// create an infinite loop that runs every frame:
while (true){
if(Input.GetKey("w") || Input.GetKey("a") || Input.GetKey("s") || Input.GetKey("d")){
yield WaitForSeconds(waitTime);
audio.PlayOneShot(footsteps);
}
if(Input.GetKeyDown("left shift")){
yield WaitForSeconds(sprintwaitTime);
audio.PlayOneShot(footsteps);
}
}
}