i have instantiated an object and made it a child to another gameobject which constantly rotates so that it rotates along with it too. after this, when the instantiated object reaches a certain position, another clone of the same object is supposed to spawn at the same place where the first one was spawned… and so on. basically i am trying to maintain a constant gap between spawned objects which have a common constantly rotating parent. this is the code i am using:
var brick : Transform;
private var curObj : Transform;
function Start () {
while (true)
{
if (!curObj || (curObj.position.y==6.5 && curObj.position.z>0))
{
curObj = Instantiate(brick, Vector3 (0, 0, 10), Quaternion.identity);
curObj.transform.parent = transform;
print(curObj.position.y);
}
yield;
}
}
the first object is spawned but the next one never spawns because the position of the spawned object never changes (maybe because it is a child of another object)…
please help me fix this.