I have written a very simple script to make a ground of blocks.
var object : GameObject;
function Start () {
for(var x = 0;x < 100;x++)
{
for(var y = 0;y < 100;y++)
{
var cube = Instantiate(object,Vector3(x,y,0),Quaternion.Identity);
}
}
}
The object variable is the prefab that it should make the ground out of. In this case a cube.
But when i run it there is no ground. And I am at 0,0,0 position in the world.
It seems you’re building a wall. x is left, y is up and z is forward. so you want to create them along the x/z axes. Also object is a reserved keyword in C#, I don’t know how this translates to JS… But try renaming the object variable.
var prefab : GameObject; // Renamed, because of uncertainty
var height : float = -1.0f; // Adjust this to find a proper height...
function Start () {
for(var x = 0; x < 100; x++)
for(var z = 0; z < 100; z++)
Instantiate(prefab, Vector3(x, height, z), Quaternion.Identity);
}