I have Unit gameObject which contains 2 subOnjects in it: Monster and HealthBar. Now Health has float - max_Health which I want to access using onTriggerEnter.
print(co.transform.GetChild(1));
Gives me "HealthBar" Which means I get correct subobject but now how can I get meaning of its float variable "max_Health" ?
I've tryied this:
print(co.transform.GetChild(1).transform.Find("max_Health"));
But got Null. That's wrong. How can I get it ?
print(co.transform.GetChild(1).Find("max_Health"));
not working
print(co.transform.GetChild(1).Find("float max_Health"));
not working.
What else can be done ??????
UPDATE
GameObject GG = GameObject.Find("GameObject co.transform.GetChild(1)");
Health bScript = GG.GetComponent<Health>();
print(bScript.max_Health);
gives me error
NullReferenceException: Object reference not set to an instance of an object
Tower.OnTriggerEnter (UnityEngine.Collider co) (at Assets/Scripts/Tower.cs:23)