So I have a GO whoose children I want to delete but if I try to do it with the following code I get an error at “i = child.transform.childCount” saying it can’t convert from BOOL to int. I have no idea where it’s geting a bool.
GameObject child = GameObject.FindGameObjectWithTag(“PickUpController”);
for (int i = 0; i = child.transform.childCount; i++)
{
child.transform.GetChild(i).GetComponentInChildren().destroy = true;
}
I have spent hours trying to fix this and after a lot of experimentation I found only this working:
GameObject child = GameObject.FindGameObjectWithTag(“PickUpController”);
int i = 0;
while (child.transform.childCount != 0)
{
child.transform.GetChild(i).GetComponentInChildren().destroy = true;
i++;
}
Thanks for the help