private void OnCollisionEnter(Collision collision) { Damageable damageable; if (collision.gameObject.TryGetComponent <Damageable>(out damageable)) { damageable.TakeDamage(damage, () => castleShipRef.AddKills(1)); } Remove(); }
private void OnTriggerEnter(Collider other) { Damageable damageable; if (other.gameObject.TryGetComponent <Damageable>(out damageable)) { if (other.gameObject == castleShip.gameObject) { return; } damageable.TakeDamage(damage, () => castleShip.AddKills(1)); Remove(); } }