示例#1
0
 void OnTriggerEnter(Collider collider)
 {
     if (collider.gameObject.tag == "Player" && navMeshAgent.enabled == true)
     {
         FpsHealthScript player = collider.gameObject.GetComponent <FpsHealthScript>();
         StartCoroutine(Attacking(player));
     }
 }
示例#2
0
    IEnumerator Attacking(FpsHealthScript player)
    {
        while (true)
        {
            player.TakeDamage(zombieData.damage);

            if (Random.value > 0.5)
            {
                zombieAudio.PlayAttackClip();
            }

            yield return(new WaitForSeconds(attackInterval));
        }
    }