I am animating a 2D escapists sprite which works ok.
By pressing the arrow keys or wasd you go in the direction you want and the animation points in that direction but the thing is, it wants to wait for the last animation to finish before moving onto the next one when you press the key causing a randomly timed delay.
It would be great if you could give me a solution.
here is the animation script and I have also attached a picture of the animator:
#pragma strict
public var anim : Animator ;
function Start () {
anim = GetComponent("Animator");
}
function Update () {
if(Input.GetKeyDown(KeyCode.A)|| Input.GetKey(KeyCode.LeftArrow)){
anim.SetBool("Left",true);
anim.SetBool("Right",false);
anim.SetBool("Up",false);
anim.SetBool("Down",false);
}
{
if(Input.GetKeyDown(KeyCode.D)|| Input.GetKey(KeyCode.RightArrow)){
anim.SetBool("Right",true);
anim.SetBool("Left",false);
anim.SetBool("Up",false);
anim.SetBool("Down",false);
}
{
if(Input.GetKeyDown(KeyCode.W)|| Input.GetKey(KeyCode.UpArrow)){
anim.SetBool("Up",true);
anim.SetBool("Right",false);
anim.SetBool("Left",false);
anim.SetBool("Down",false);
}
{
if(Input.GetKeyDown(KeyCode.S)|| Input.GetKey(KeyCode.DownArrow)){
anim.SetBool("Down",true);
anim.SetBool("Right",false);
anim.SetBool("Up",false);
anim.SetBool("Left",false);
}
}
}
}
}