I know I need to use rigidbody.AddForce, But I'm having trouble finding how.
This is what I have, but when I start the game, it spawns the object randomly but doesn't add and force to it. Any help would be greatly appreciated.
var asteroid : Transform;
var asteroidSpeed : float = -200.00;
var spawnAsteroid : boolean = false;
var ran1 : float;
var transPos : float;
function Update (){
if(spawnAsteroid == true){
if(Input.GetButtonDown("Jump")){
var Asteroid : Transform;
asteroid = Instantiate(asteroid, transform.position, transform.rotation);
asteroid.rigidbody.AddForce(transform.right * asteroidSpeed);
}
}
}
↧