When the player holds mouse 1, I want a charging animation to play once, and the attack animation to then loop. I have the animations themselves down, and a collider is activated upon attacking, however the collider is also present while charging, as the charging animation leads into the attack animation.
How do I make it so that the collider is only active during the attack animation.
public class Hand : MonoBehaviour {
private Animator anim;
public CapsuleCollider cc;
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
cc.enabled = false;
}
// Update is called once per frame
void Update () {
if (Input.GetButton("Fire1"))
{
anim.SetBool("IsNoInput", false);
anim.SetBool("IsCharging", true);
anim.SetBool("IsAttacking", false);
}
else
{
anim.SetBool("IsNoInput", true);
anim.SetBool("IsCharging", false);
anim.SetBool("IsAttacking", false);
}
if (anim.GetBool("IsAttacking") == true)
{
cc.enabled = true;
}
if (anim.GetBool("IsAttacking") == false)
{
cc.enabled = false;
}
}
public void ActiveCollider(int active)
{
if (active == 0)
cc.enabled = false;
else
cc.enabled = true;
}
}
This current code has the charging animation play, but it stops at the last frame and doesn’t move on to the attack animation. If it helps at all the charging animation is .708 seconds long.