I wanted the walking animation to crossfade for my character if any of the WASD keys are pressed. This works fine, but I also wanted the standing animation to crossfade when all WASD keys are not being pressed and then wait 4 seconds before crossfading to the idle animation. Here is my script:
#pragma strict
function Update () {
if(Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.S)) {
animation.CrossFade("walk");
}
if(Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.D) || Input.GetKeyUp(KeyCode.S)) {
animation.CrossFade("standing");
yield WaitForSeconds(4);
animation.CrossFade("idle");
}
}
Instead of doing what I want it to do, it doesn’t play any animations at all unless I have “Play Automatically” on, in which case it only plays that main animation and nothing else. Could someone please help me understand this?
PEMLOKIS (Please Excuse My Lack Of Knowledge In Scripting)