using UnityEngine; public class States : MonoBehaviour { public bool isDead = false; public float maxHP = 100; private float myHP = 100; private void Start() { myHP = maxHP; } private void Update() { } private void DetactDeath() { if (myHP <= 0) { Destroy(this.gameObject); isDead = true; } } // while got hit public void ReactToHit(float Damage, GameObject damageSource) { myHP -= Damage; Debug.Log("HP:" + myHP); if (myHP <= 0) { if (damageSource.tag == "Player") { damageSource.GetComponent().KillRecord(transform.position); Destroy(this.gameObject); isDead = true; } else { Destroy(this.gameObject); isDead = true; } } } // get my hp from other script public float GetnowHP() { return myHP; } public void DestroyMe() { Destroy(this.gameObject); isDead = true; } }