- Home /
Question by
maro101 · Sep 29, 2012 at 08:05 AM ·
instantiatearray
Problems - instantiate, arrays
why cant I instantiate an object from an array like this, and how do I parent the current Instantiation to the previous instantiation
var spawnpoints : GameObject[];
var track : Transform[];
var instant : GameObject[];
var counter : boolean= false;
var a : int;
function Start () {
instant[0] = Instantiate(track[Random.Range(0, track.length)], spawnpoints[Random.Range(0, spawnpoints.length)].transform.position);
}
function Update () {
	for( a = 1; a<100; a++){
		instant[a] = Instantiate(track[Random.Range(0, track.length)], spawnpoints[Random.Range(0, spawnpoints.length)].transform.position);
		instant[a-1].transform.parent = instant[a].transfrom;
	}
}
Comment