I want to make a horse play it’s idle animation when no key is pressed, it’s walking animation when W, A, S, or D is pressed, and its running animation when the left shift is pressed. I just want to know how my script should be changed in order for this to happen.
#pragma strict
public var Run : AnimationClip;
public var Walk : AnimationClip;
public var Idle : AnimationClip;
function Update () {
GetComponent.<>(Idle).Play();
if( Input.GetKeyDown("W")){
GetComponent.<Animation>().Play();
}
if( Input.GetKeyDown("A")){
GetComponent.<Animation>().Play();
}
if( Input.GetKeyDown("S")){
GetComponent.<Animation>().Play();
}
if( Input.GetKeyDown("D")){
GetComponent.<Animation>().Play();
}
if( Input.GetKeyDown("LeftShift")){
GetComponent.<Animation>().Play();
}
}