using UnityEngine; public class EnemyDamage : MonoBehaviour { [SerializeField] protected float damage; protected void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Player") { Health playerHealth = collision.GetComponent(); if (playerHealth != null) { playerHealth.TakeDamage(damage); } else { Debug.LogError("No Health component found on the Player object!"); } } } }