Hello people,
I have today just started to try out Unity and have learned a lot so far.
Now I want to give my character a walking sound. I found some example script on the internet and tried that. It works, in a way, when I keep holding the W the sound will play every millisecond causing some sort of static sound. What I would like to have is the sound to play until its finished and if the W is still pressed it should play again et cetera.
____________
This is my current code:
var AudioFile : AudioClip;
function Update() {
if (Input.GetKey (KeyCode.W))
{
audio.clip = AudioFile;
audio.Play();
}
}
______________________
Beware, I'm very nooby and can read/understand script but I can't write it yet.
Thanks in advance.
↧