I am creating objects using script ( Instantiate function ), but how to parent created objects to something? I’ve already attached the script to the object, that will be a father. But can’t write normal script for parenting. I ended with something like that:
public GameObject prefab;
public int numberOfObjects = 20;
public float radius = 5f;
void Start() {
for (int i = 0; i < numberOfObjects; i++) {
float angle = i * Mathf.PI * 2 / numberOfObjects;
Vector3 pos = new Vector3 (Mathf.Cos (angle), 0, Mathf.Sin (angle)) * radius;
GameObject BrickPrefab = Instantiate (prefab, pos, Quaternion.identity);
GameObject prefab = BrickPrefab.Find("clone");
prefab.transform.parent = transform;
}
}
}
But something is definitely wrong here.