I have a foreach loop that instantiates gameobjects.
What im trying to achieve is for the loop to get the position of a child in the last instantiated gameobject and update a variable according to that.
Here’s what i’ve got so far:
foreach(GameObject seam in seams)
{
if (isgenerating) {
Instantiate (seam, genlastpos, Quaternion.identity);
genlastpos = seam.transform.GetChild (0).position;
seamno++;
}
else
{
return;
}
}
The only problem is that i know only how to access the first gameobject.
What would be the most efficient way to do this? Thanks in advance.