void OnTriggerEnter(Collider collidee) { if (collidee.tag.Equals("enemy")) { bool hasEnemies = false; hitColliders = Physics.OverlapSphere(gameObject.transform.position, explosionradius); int i = 0; while (i < hitColliders.Length) { if (hitColliders[i].tag == "enemy") { enemy = hitColliders[i].GetComponentInParent<NavAgent>(); enemy.takeDamage(dmg); Debug.Log("DESTROY THAT SHIT"); hasEnemies = true; } i++; } if (hasEnemies) { Destroy(gameObject); } } }
void OnTriggerEnter(Collider collidee) { if (Time.time > nextfire && collidee.tag == "enemy" && ammo >= 0) { enemy = collidee.GetComponentInParent<NavAgent>(); enemy.takeDamage(dmg); nextfire = Time.time + firerate; Debug.Log("Murder stuff"); ammo--; } if(ammo <= 0) { Destroy(gameObject); } }