I’ve marked an “if” with " ** " to locate the problem.
public float speed = 2.0f;
public float rotationSpeed = 75.0f;
float translation = Input.GetAxis("Vertical") * speed;
float rotation = Input.GetAxis("Horizontal") * rotationSpeed;
translation *= Time.deltaTime;
rotation *= Time.deltaTime;
transform.Translate(0, 0, translation);
transform.Rotate(0, rotation, 0);
**if ((Input.GetMouseButtonDown(0)) && (translation == 0)) //Attack**
{
anim.Play("Attack");
}
// Transition Walk / Run
if ((translation != 0) && (speed == 8))//Run animation
{
anim.SetBool("Walk", false);
anim.SetBool("Run", true);
} else
if ((translation != 0) && (speed == 4))//Walk animation
{
anim.SetBool("Run", false);
anim.SetBool("Walk", true);
} else //stay still(Idle) animation
{
anim.SetBool("Run", false);
anim.SetBool("Walk", false);
anim.SetBool("Idle", true);
}
// End of transition Walk / Run