IEnumerator Attack(SfpsHealthBase target, float interval) { while (!target.Dead()) { target.TakeDamage(1); yield return(new WaitForSeconds(interval)); } }
void Fire() { // Check for impact. If absent, return. RaycastHit hit; if (!Physics.Raycast(playerCamera.transform.position, playerCamera.transform.forward, out hit, Mathf.Infinity)) { return; } // Check if Zombie is hit if (hit.collider.gameObject.tag == "Zombie") { SfpsHealthBase zombie = hit.collider.gameObject.GetComponent <SfpsHealthBase>(); zombie.TakeDamage(1); } }