I’m trying to take a gameobject in a script, and assign it to a gameObject that is childed under a parent.
void SelectPillar()
{
GameObject GO = GameObject.Find("Pillars"+pillarEnemy+"(Clone)");
int GOChildNum = GO.transform.childCount;
int randomSpawn = Random.Range (0,GOChildNum);
goodPillar = GO.transform.Find("Pillar"+randomSpawn+"(Clone)");
}
goodPillar is a gameObject, GO is the parent that has already spawned ingame, and “Pillar”+randomSpawn+“(Clone)” is the child.
I’m getting an error that says I cant assign a gameobject to a transform, but I don’t see how the child is a transform. It should just be a gameObject.