- Home /
Creating a 'tiled' grid from custom object.
Hi there,
At the moment I have a game object (it's a cube) and it has some scripts attached, mainly touch user interface from UniTUIO, so for example when pressed the cube flips around, or if the mouse/pointer goes across it, it wobbles. Works fine.
I would like to duplicate this object, so its tiled, a bit like on face of a Rubik cube, or a bathroom floor with grouting. I know I cold duplicate the asset and do it by hand, but that seems like a pain. Especially if it's a large grid.
So is there an easy/automated method to make a grid of objects?
Thanks
Answer by Eric5h5 · Jun 02, 2011 at 04:17 PM
Use a loop:
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++) {
Instantiate(prefab, Vector3(i, 0, j), Quaternion.identity);
}
}
Right, and slap ExecuteInEdit$$anonymous$$ode on there to have it done in the editor.
How could you adjust the distance between the GameObjects ? Thanks
Answer by Wixar172 · Feb 06, 2017 at 08:32 AM
check this tutorial, it has distance adjustment too. https://wixarexperience.com/2017/02/03/quad-or-objects-grid-creation-for-unity-3d-tutorial-c/