private void OnCollisionEnter2D(Collision2D target) { if (target.gameObject.tag == "Enemy" || target.gameObject.tag == "Boss") { BaseEnemyBehaviour enemy = target.gameObject.GetComponent <BaseEnemyBehaviour>(); enemy.TakeDamage(damage); DecreaseEnergy(); } }
void HandleCollision(GameObject target) { if (target.tag == "Enemy" || target.tag == "Boss") { BaseEnemyBehaviour enemy = target.GetComponent <BaseEnemyBehaviour>(); enemy.TakeDamage(1); if (health <= 0) { Destroy(this.gameObject); } } }