private void OnTriggerEnter(Collider other) { if (!other.isTrigger) { IHealthController target = other.gameObject.GetInterface <IHealthController>(); if (target != null) { target.Damage(damage); hitBox.enabled = false; } } }
private void OnCollisionEnter(Collision collision) { Boat waterObject = collision.gameObject.GetComponentInParent <Boat>(); if (waterObject != null /* && firedBy != waterobject*/) { waterObject.Velocity.v += (shotPosition - collision.transform.position).normalized * cannonBallForce / 10; waterObject.Mass += 100; Destroy(this); } else { IHealthController h = collision.gameObject.GetInterface <IHealthController>(); if (h != null) { h.Damage(15); Destroy(this); } } }