private void OnCollisionEnter2D(Collision2D collision) { Debug.Log("EnemyBAse: OnCollisionEnter2D"); // todo::get dumage from trap and apply it Trap trap = collision.gameObject.GetComponent <Trap>(); if (trap && trap.CanDealDamage()) { TakeDamage(trap.DamageDealt); } InteractablePart interactible = collision.gameObject.GetComponent <InteractablePart>(); if (interactible) { Loot loot = interactible.GetMainGameObject().GetComponent <Loot>(); if (loot) { loot.DestroyByEnemy(); } } }