public void FireStreaming() { //CurrentWeapon = WeaponSelection.ActiveWeaponNumber; //var power = "weapon" + (CurrentWeapon + 1) + "speed"; //CurrentWeaponSpeed = PlayerPrefs.GetFloat(power); //Debug.Log("CurrentWeaponSpeed " + CurrentWeaponSpeed); nextTimeToFire = (Time.time + 1f / fireRate); RaycastHit hit; if (Physics.Raycast(partToRotate.position, partToRotate.forward, out hit, range)) { particalStream.Play(); anim.SetBool("Fire", true); ZombieHealth zombieHealth = hit.collider.GetComponent <ZombieHealth>(); if (zombieHealth != null) { zombieHealth.DamageTaken(Damage); } } else { particalStream.Stop(); anim.SetBool("Fire", false); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Enemy") { ZombieHealth zombieHealth = other.GetComponent <ZombieHealth>(); if (zombieHealth != null) { zombieHealth.DamageTaken(damage); Destroy(gameObject); return; } } }
private void OnTriggerEnter(Collider other) { Collider[] colliders = Physics.OverlapSphere(transform.position, ExplosionRadius); for (int i = 0; i < colliders.Length; i++) { Rigidbody targetRigidbody = colliders [i].GetComponent <Rigidbody> (); if (targetRigidbody != null) { targetRigidbody.AddExplosionForce(explosionForce, transform.position, ExplosionRadius); ZombieHealth zombieHealth = other.GetComponent <ZombieHealth> (); if (zombieHealth != null) { zombieHealth.DamageTaken(damage); Destroy(gameObject); return; } } } }