Question by
ghdwoals112 · Apr 10, 2018 at 05:51 PM ·
errorexception
I don't know how to fix 'Transform child out of bounds' exception.
Hi. I'm going to make child gameobject setactive = true when parent gameobject is Triggered.
Like this picture, BallIndigo1 is parent gameobject and x is child gameobject which is in setactive(false).
and I made a code like this.
void OnTriggerEnter2D(Collider2D col){
if(col.gameObject.activeSelf == true)
{
if (col.transform.GetChild(0) != null)
{
col.transform.GetChild(0).gameObject.SetActive(true);
}
else
{
Debug.Log("No child");
}
}
}
But the result says
I don't know why this happened and how to fix it.
Help me please..
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612160450im_/https://answers.unity.com/themes/thub/images/avi.jpg)