|
I really need to do this, but im pretty new programing so i dont know where begin. What i need is create a grid with colums and rows to instantiate a series of prefabs on scene on determinate distance, and be able to put and change them within the inspector. I was thinking about some loop var, but i cant figure how to do it. Aprecciate so much your help.
(comments are locked)
|
|
The Manual page on Instantiate has sample code how to do this. One only problem, this is good to instantiate the same object, do you know how to make it to instantiate prefabs from an array?? Thanks again
Sep 02 '11 at 01:49 PM
NE07HEKIN6
What does the array look like? Do you have different objects for every grid tile, objects that repeat or objects that is defined by you where they should be? How many objects are there? Basically just bring that array (if you have it constructed) into the for-loop and go wild with it (if(objArray[i]), if(i%5) and so forth). :-)
Sep 02 '11 at 02:09 PM
save
they are prefabs that make the scenary of the game, every one is put in a number on the array, 1, 2, 3, so on, so if you change a prefab you can modify the scenary, so are some prefabs that are repeated and some that have no repetition. The array looks like the drawing i put up, its a x*y array. I can do this by hand, but i think it would be nicer to find out a code to instantiate prefabs on the inspector in an automatic way.
Sep 02 '11 at 02:18 PM
NE07HEKIN6
(comments are locked)
|
|
I already did it, was simple after all, i post it in case someone needs it var cube : Transform[]; function Start () { for (var y = 0; y < 5; y++) { for (var x = 0; x < 5; x++) { for (var z = 0; z < x*y; z++) { var cube = Instantiate(cube[z], Vector3 (x, y, 0), Quaternion.identity); } } } }
(comments are locked)
|

