private void HitSomething(IEnemyHittable hitObject) { hitObject.Hit(damageOnHit, transform.position); if (destroyWhenHit) { Destroy(gameObject); } }
private void CheckCollidersOverlap() { int collisionsCount = thisCollider.OverlapCollider(contactFilter, overlapingColliders); for (int i = 0; i < collisionsCount; i++) { if (overlapingColliders[i] != null) { IEnemyHittable enemyHittable = overlapingColliders[i].attachedRigidbody.GetComponent <IEnemyHittable>(); if (enemyHittable != null) { if (HitSomething != null) { HitSomething(enemyHittable); } } } } }
protected virtual void HitSomething(IEnemyHittable objectHit) { objectHit.Hit(damageOnHit, transform.position); }
protected override void HitSomething(IEnemyHittable objectHit) { base.HitSomething(objectHit); hitSomething = true; }