for structure ( generating objects )

Is there in Unity script something like a for structure

this is an Example from processing:

for (int i = 0; i < 10; i = i++) {
  for (int j = 0; j < 10; j = j++) {
    point(i, j);
  }
}

It generates points in a Matrix 10x10. Is there something similar to instanciate prefabs into the scene? I did not find anything in the refference.

Not sure I understand the question? You want to create objects IN the array, or create them in world, from the array, or position them based on the array?

Were you looking for instanciate? Because it’s actually written with a ‘t’, not a ‘c’. :wink:

Object.Instantiate

Hurra, thats it,Thank you:

var prefab : Transform;
for (var i=0;i<10;i++) {
Instantiate (prefab, Vector3(i * 2.0, 0, 0), Quaternion.identity);
}

i did not knew if this was done this way in jscrip, but it is.
Instantiate copies the Prefab
And the for repeats the process and is used for the coordinate. What i don’t understand is: Quaternion.identity ?

A quaternion gives a more robust way of handling rotations, look it up in the Unity reference or wikipedia for detailed info.

The identity quaternion is one that has a rotation of zero on all axes. If you set an object’s rotation to the identity all of its local axes will be lined up with the world axes. So in effect, this resets its rotation.

understood, thanks :slight_smile: