using System; using UnityEngine; public class LivingEntity : MonoBehaviour { public float health; public void Damage(float amount) { health -= amount; if (health <= 0) { Destroy(gameObject); } } private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.layer == LayerMask.NameToLayer("Bullet")) { Destroy(gameObject); other.gameObject.SetActive(false); } } }