private void AttackTree() { if (!animationAttackStateBeenSet) { SetAttackState(); } treeToAttack.TakeDamage(damage); readyToAttack = false; StartCoroutine(DisableAttack()); }
void Attack() { // if(!initialized || finding) { // return; //} if (treeHealth.currentHealth > 0 && Time.time >= nextFire && enemyHealth.currentHealth > 0) { animator.SetTrigger("attack"); treeHealth.TakeDamage(attackDamage); nextFire = Time.time + timeBetweenAttacks; attacking = true; //play audio int i = Random.Range(0, attackClip.Length); audioSource.PlayOneShot(attackClip[i], 0.5f); } else { attacking = false; } }