Hi I am new in unity and I have problems making clones of my Enemy.
The problem is I have a compounded Enemy with different health in each bodypart, every body part have its own script with its own health and events, for example, in one of my Leg Scripts I have if (OtherLeg.GetComponent().LegHealth2 <= 0 && LegHealth <= 0) { Destroy(Enemy); }
I have seen other scripts and they have health in another script and when health is 0 and they only destroy the gameObject, but in my case I can’t do that because if I reference the other Leg or my main enemy the script will destroy all enemies and body parts referenced. Is there a way to reference gameobjects inside the same hierarchy? Maybe are better solutions, anything helps.
Well I figured out myself you can actually get the parent and the siblings of my gameObject script with:
transform.parent.gameObject transform.parent.parent.GetChild(0)