public override void Shoot() { TimeSinceFire = 0; FireSource.Play(); CurrentMag--; Ray ray = Camera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.transform.tag == "zombie") { zombieHealth.DealDamage("Rifle", hit.transform.gameObject, Vector3.Distance(ray.origin, hit.transform.position)); } } }
public override void Shoot() { TimeSinceFire = 0; FireSource.Play(); CurrentMag--; for (int i = 0; i < ProjectileCount; i++) { float x = Random.Range(0.4f, 0.6f); float y = Random.Range(0.4f, 0.6f); Ray ray = Camera.ViewportPointToRay(new Vector3(x, y, 0)); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.transform.tag == "zombie") { zombieHealth.DealDamage("Shotgun", hit.transform.gameObject, Vector3.Distance(ray.origin, hit.transform.position)); } } } }