I have a problem with getting the animation to play using Input.GetAxis("Horizontal").
I want the animation to play the walking animation while the user still has right or left pressed.
here is my current implementation and its not working. The animation just stops and it moves forward and will continue playing after i stop pressing the button.
void Update()
{
transH = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
if (transH > 0.0f)
{
transform.Translate(transH, 0, 0);
anim.Play("walk_right");
anim.animationCompleteDelegate = null;
}
if (transH < 0.0f)
{
transform.Translate(transH, 0, 0);
anim.Play("walk_left");
anim.animationCompleteDelegate = null;
}
}
please help. thanks