I’m trying to get these objects in a line connected to each other but it’s not working out too well.
void StackUp()
{
tempHolder = new GameObject("Holder").transform;
tempHolder.SetParent(boardHolder);
GameObject instance;
for (int y = startPos; y < endPos; y++)
{
GameObject toInstantiate = lineTiles[Random.Range(0, lineTiles.Length)];
instance = Instantiate(toInstantiate, new Vector3 (0, currentPos, 0f), Quaternion.identity) as GameObject;
currentPos += (float)instance.GetComponent<Collider2D>().bounds.size.y;
instance.transform.SetParent(tempHolder);
}
}
The objects in lineTiles are different sizes in height and width.
I can’t seem to get them to stay connected though. I think it would have to do with currentPos but no idea what I’m doing wrong to get it like this:
There are also some objects hidden under each other: