In my game I am trying to make it so that when a cube hits a player the player gets knocked off the platform. I have looked at a few ways to do this but I would like to try and use the rigidbody.AddForce function. this is the code I have so far:
#pragma strict
//var rocket : Rigidbody;
// speed = 10.0;
var numEnemies : int = 3;
function Update () {
for(var i : int = 0; i < numEnemies; i++)
{
rigidbody.AddForce(Vector3.forward*500,ForceMode.Acceleration);
}
//var rocketClone : Rigidbody = Instantiate(rocket, transform.position, transform.rotation);
//rocketClone.velocity = transform.forward * speed*1;
}
The code works but only once and then stops. so I tried to add a for loop but it does not work
can anyone help please?
Thanks