Hey guys, so I’m having trouble where I’m trying to get my run animation to stop and play my attack animation. For some reason it would never do that, is my logic correct? Also i’m using an animation controller for the animations.
void MovePlayer()
{
translation = Input.GetAxis("Vertical") * moveSpeed;
anim.SetFloat("Speed", translation);
anim.speed = animSpeed;
translation *= Time.deltaTime;
transform.Translate(0, 0, translation);
}
void PlayerAttack()
{
if (currentBaseState.nameHash == idleState)
{
if (Input.GetButtonDown("Attack"))
{
anim.SetBool("Atk", true);
anim.SetFloat("Speed", 0.0f);
}
else
{
anim.SetBool("Atk", false);
}
}
if (currentBaseState.nameHash == runState)
{
if (Input.GetButtonDown("Attack"))
{
anim.SetBool("Atk", true);
anim.SetFloat("Speed", 0.0f);
}
else
{
anim.SetBool("Atk", false);
}
}
}