Ok to be specific, both of my enemies will continuously play their attack animation even when it is false. I don't understand what I am doing wrong here :(
void OnTriggerEnter2D(Collider2D other){
//If attack collider is player and we're not attacking
if (other.name == "Player" && !attacking) {
attacking = true;
attackTimer = attackCD;
}
if (attacking)
{
if (attackTimer > 0)
{
Debug.Log ("Decreasing");
attackTimer -= Time.deltaTime;
}else if (attackTimer == 0)
{
attacking = false;
Debug.Log ("Done attacking!");
//attackTimer = attackCD;
}
}
}
anim.SetBool ("Attack", attacking);//This sets the animation but it is in my Update function not my OnTriggerEnter2D function