// Make all rigidbodies we touch fly upwards
function OnCollisionStay(collision : Collision) {
// Check if the collider we hit has a rigidbody
// Then apply the force
if (collision.rigidbody) {
collision.rigidbody.AddForce (Vector3.up * 15);
}
}
i got this from the scripting reference in the docs, and it wont work, i checked to see if its entering the if statement and it is, but the rigid body wont go upwards
Most likely the force is too small. Try changing it to this and giving it a large force in the inspector.
var force = 0.00;
// Make all rigidbodies we touch fly upwards
function OnCollisionStay(collision : Collision) {
// Check if the collider we hit has a rigidbody
// Then apply the force
if (collision.rigidbody) {
collision.rigidbody.AddForce (Vector3.up * force);
}
}
You’re not specifying a force mode. If you make your third parameter ForceMode.Force, it should apply that force instantly over one frame. It’s probably applying that force over time, making it super weak.