- Home /
Question by
Aydan · Nov 29, 2011 at 11:27 AM ·
instantiatearraycubes
How do I create an array of cubes?
Hello I am woundering how would I create a plane of cubes using an array like a grid of 100x100 cubes?
Comment
Best Answer
Answer by Aydan · Nov 29, 2011 at 12:05 PM
Found the answer:
var prefab : GameObject;
var x = 100;
var z = 100;
function Start () {
for (i = 0; i < x; i++) {
for (j = 0; j < z; j++) {
Instantiate(prefab, Vector3(i, 0, j), Quaternion.identity);
}
}
}
Thanks, i've been looking 2 days for an easy solution for this problem myself and this is the first one that actually worked!!
Your answer
Follow this Question
Related Questions
Spawn from array 2 Answers
Instantiating prefab at child (spawnlocations are arrays) 2 Answers
Need to spawn a gameobject from an array 1 Answer
Array won't be filled by Instantiate 1 Answer
Instantiate problem with multiple objects from an array 0 Answers