- Home /
Error with Array declaration
i want to declare an array that can store my cloned game objects as they are spawned but the compiler is showing me this error ....pls help.I am a newbie so any suggestions with the code would be appreciated=S var arrayClones : GameObject(); function Start(){ myAngle=Random.Range(45,135);
for (var i: int=0; i<numberOfClones;i++){ var myClone: GameObject=(Instantiate(mySphere,Vector3(seperation*i,-7,-3),Quaternion.identity) as GameObject);
var myBody: Rigidbody=myClone.rigidbody;
myBody.AddForce(-100,700,0);
print("Sphere Down!"+i);
myClone.name="Sphere"+i;
arrayClones.Add(myClone);
print("clone name is"+myClone.name);
Debug.Log("my arrayClone is "+arrayClones);
}
}
ERROR:Assets/Test/ForceTest.js(6,29): UCE0001: ';' expected. Insert a semicolon at the end.
$$anonymous$$issed some of the code posted here from proper format , could you fix that please? Thanks in advance!
LOL,this is the only code as i told you am a newbie so working out basic datatypes with unity=)
Answer by Mike 3 · Apr 11, 2011 at 07:19 AM
This line:
var arrayClones : GameObject();
should probably be:
var arrayClones = new Array();
@$$anonymous$$ike:Thanks,Now its working.Would you tell me why did you add "new" in there but i guess it is working fine without it too.