# How do I change force of gravity for a single object?

I’ve got an object that I want to fall at an acceleration of 3 G’s. My current method of doing this is to turn gravity off for the object, and apply a downward force of 3*Physics.gravity each tick. Unfortunately, applying a force every tick prevents the rigidbody from ever sleeping.

My hope is to have a lot of these objects, have them fall, and once they reach a resting place, put the rigidbody to sleep. This all works as expected if I let the rigidbody use its built-in gravity, but then I can’t modify the gravity force for individual objects.

Anybody know how to solve this?

You can apply a force as you were already doing, but check rigidbody.velocity: when it’s below a low value during some number of consecutive physics cycles, remove the force and let the rigidbody sleep like a log:

``````private var limit: float = 0.01;
private var cycles: int;
private var cyclesToSleep: int = 10;

function FixedUpdate () {
if (rigidbody.velocity.sqrMagnitude > limit){
cycles = cyclesToSleep; // reload counter if velocity isn't negligible
}
if (cycles > 0){ // while counter > 0 apply force
cycles--;
}
}
``````

If something hits and moves the rigidbody, the force is re-enabled.

You could turn gravity off and apply a constant force, and then turn that constant force off or manipulate the constant force to your specifications. You can add a constant force a rigidbody by going to component → physics → constant force. Or you can change the constant force by script if you wish:

http://unity3d.com/support/documentation/ScriptReference/ConstantForce.html

You can try to apply by default a very strong gravity (3G’s) but put a big drag on your rigidbodies to make them look as they were falling at only one G.

Then if you need an object to fall at 3G’s, just put the drag to zero (or a very small value).

Physics.gravity = new Vector3(0, -1.0F, 0);