- Home /
Question by
Zombins · Oct 12, 2020 at 09:33 PM ·
c#gameenemy damagehealth
Make enemy damage player
I have two separate scripts, one controlling the enemy attack, and one for player health, the enemy can properly attack and even tested using Debug.Log, but i can't get it to respond with the health script
Comment
Answer by omeerdvrn · Oct 13, 2020 at 08:28 AM
You can make the health script Singleton. If the health class name is "healthScript" and health int is "health" you can call it like "healthScript.GetInstance().health -= 10;" private static healthScript _instance; private void Awake() { if(_instance == null){ _instance = this; DontDestroyOnLoad(this); } else { Destroy(this); } } private static healthScript GetInstance() { return _instance; }