void OnTriggerEnter(Collider collider) { if (collider.gameObject.tag == "Player" && navMeshAgent.enabled == true) { FpsHealthScript player = collider.gameObject.GetComponent <FpsHealthScript>(); StartCoroutine(Attacking(player)); } }
IEnumerator Attacking(FpsHealthScript player) { while (true) { player.TakeDamage(zombieData.damage); if (Random.value > 0.5) { zombieAudio.PlayAttackClip(); } yield return(new WaitForSeconds(attackInterval)); } }