- Home /
Question by
blackstorm39 · Jan 31, 2014 at 05:36 AM ·
javascriptspawningcube
Spawning won't work
I am writing a script to spawn a mass of cubes when I press X. When I try to run it unity say unexpected token.
// JavaScript
function Start ()
if(Input.GetButtonDown("X"))
{
for (var y = .5; y < 10; y++) {
for (var x = 0; x < 10; x++) {
for (var z = 0; z < 10; z++) {
var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.AddComponent(Rigidbody);
cube.rigidbody.mass = 10;
cube.transform.position = Vector3 (x, y, z);
print ("made");
}
}
}
}
Comment
Answer by getyour411 · Jan 31, 2014 at 05:37 AM
You don't want that in Start, you won't be able to push the desired buttonDown before Start is done. Replace "X" with KeyCode.X
Your answer
Follow this Question
Related Questions
How do you move a cube with javascript 2 Answers
cube spawn next to another cube in the same row 1 Answer
How to make a Cube with a texture in a JavaScript? 0 Answers
character moving after moving 0 Answers
Up and Down Cubes Shaking Issue. 0 Answers