In my game every period of time spawns a number of blocks, then all of them move down as one line. For player it should look like this line is not devided on blocks. Max amount of blocks in line - 7, but can be situations, when number of block are missing in different positions, for example it can look like:
||||||| - when all line is filled. |||.|… - when some blocks are missing(. is empty space)
or the line could be empty at all.
But in any way this line should have some element, that will trigger, when it riches the bottom of the screen, so that another line spawns at the top and the screen is never empty. This game looks like Piano Tiles, I guess . So the question is: what would you use to position block correctly and to have a trigger element? I thought, that I could use Grid layout Group to position blocks on it, and then move it down to the bottom of the screen, but I didn’t get how to work with it correctly and if it can do what i need at all.
Good day.
First, you have to Instantiate an EmptyObject (lets call “Line”), which will be the parent of all blocks of the line.
GameObject LineToInstantiate = Instantiate (LinePrefab, position, rotation);
Then, instantiate all objects as a child of “Line”, and change its LocalPosition (position relative to parent)
GameObject CubeToInstantiate = Instantiate (CubePrefab, LineToInstantiate.transform);
CubeToInstantiate.transform.Localposition = new Vector3 ( 15 , 0, 0 ) ;
PD: Don’t copy the code, maybe have typing errors
Now, you have a Object called “line” which contains the blocks you just instantiated.
If helped, accept the answer and close the question!
Bye!