void OnCollisionEnter2D(Collision2D collision) { collisionTarget = collision.collider.gameObject.GetComponent <HealthBehaviour>(); if (collisionTarget != null) { damageSuccessful = collisionTarget.TryToDamage(damage); if (damageSuccessful) { //Debug.Log(gameObject.name + " dealt " + damage + " damage to " + collisionTarget.gameObject.name); } else { Debug.Log(gameObject.name + " failed to damage " + collisionTarget.gameObject.name + ". Target might be invincible."); } } }