Prefabs instantiating at wrong spot

Hi,
I am trying to make a simple astroid game, but the astroids and bullet prefabs keep instantiating at the wrong location, at 0,0,0. The astroids should move in random directions when they spawn at random locations, but they only move in 90 degrees. Here’s the astroid code. Thanks.

//var spawnPoint : Transform;
var spawnAreaRange = 50;
var waitTime = 1;
var astroid : Rigidbody;
var ship : Transform;
var maxAstroids = 15;

function Start () {
	Spawn();
}

function Update () {

}
function Spawn(){
	for(var i = 0; i <= 15; i++){
		var clone : Rigidbody;
		clone = Instantiate(astroid, Vector3(Random.Range(ship.position.x,ship.position.x + 150.0),0 ,Random.Range(ship.position.z, ship.position.z + 150.0)),Quaternion.identity);		
	}
}

Another problem i’m having is that once the astroids instantiate, they wait 15-20 seconds to excecute any other code. Thanks in advance.

1 Answer

1

You need to add a random force to ‘clone’ after Instantiate