Hey. I made a jumping sound script, but I am receiving problems from it. I've been working on fixing this script for a very long time, but seem to be getting no were. At some point the script works nicely, but the "Yield WaitForSeconds(3)" does not work to set the "Keypressed" function to true. In other words, what I am trying to get this to do is trigger a jumping noise if "keypressed" is false. then if the jump was successful "keypressed" would change back to false after 3 seconds.
this is what I got.
var AudioNoise : AudioClip;
var keypressed = false;
function Update(){
if(keypressed == false && Input.GetKeyDown("space")){
keypressed = true;
audio.PlayOneShot(AudioNoise);
}
if(keypressed == true){
yield WaitForSeconds(3);
keypressed = false;
}
}
thank you. :)
↧