Hello
I have an object with 50 child. There are groups in it. When the number of children falls below a certain number, I want it to be created from the same object. Can you help?
private void Update()
{
if (Vector3.Distance(this.gameObject.transform.position,CloseGrounded.position)<1f)
{
BackBody();
}
}
void BackBody()
{
foreach (GameObject go in LosingBodyParts)
{
if (go.transform.childCount < 2)
{
for (int i = 0; i <10; i++)
{
GameObject a = Instantiate(prefabSphere, go.transform.position, Quaternion.identity);
a.transform.SetParent(LosingBodyParts[0].transform);
}
}
}
}