# How To Set Individual Rigidbody Gravity [Solved]

This is not a question, but a solution.

After about an hour of searching for this answer, I spent an hour working out the solution.

It is super simple.

Code:

``````	[HideInInspector] new public Rigidbody rigidbody;

public bool useGravity = true;

void Awake() {
rigidbody = GetComponent<Rigidbody>();
}

void FixedUpdate() {
rigidbody.useGravity = false;
if (useGravity) rigidbody.AddForce(Physics.gravity * (rigidbody.mass * rigidbody.mass));
}
``````

If only the Rigidbody.useGravity is true, then it will fall as per the global Physics.gravity value.

AddForce(Physics.gravity) will achieve the exact same result if Rigidbody.useGravity is false.

If Rigidbody.useGravity is true, then both forces will be applied, so the Rigidbody.useGravity bool must be false to replicate and customize the object’s gravity.

## FixedUpdate() sets Rigidbody’s useGravity to false to ensure it stays off.

Modify as desired. Using the Rigidbody.mass value is great.

However, if set to (Physics.gravity x rb.mass), nothing will change. It strangely seems like the gravity is first divided by the mass before completing the gravity x mass operation.

That is simply fixed by squaring the mass. (mass x mass)

If the mass is 2, the object will fall by gravity x 2 as expected.

This answer is wrong. If you want them to fall at the same acceleration or another acceleration value, to simulate say gravity on the moon.

Objects don’t fall as a function of their mass.

``````private Rigidbody rb;
void Start()
{
rb=GetComponent<Rigidbody>();
}

void FixedUpdate()
{
rb.AddForce(Physics.gravity*rb.mass);
}
``````

If you want to give another value of gravity, say your game environment is the moon.

``````private Rigidbody rb;
public float gMoon=1.6f;  //gravity on the moon.
void Start()
{
rb=GetComponent<Rigidbody>();
}
void FixedUpdate()
{
rb.AddForce(new Vector3(0, -1.0f, 0)*rb.mass*gMoon);
}
``````

If you want to test yourself. Drop two rigidbodies side by side from the same height. One just has useGravity=true, the other set to false. Attach this artificial gravity script to the other and watch them fall side by side. Vary the mass of the artificial gravity rigicbody and you will see that the acceleration is independent of it’s mass.

Make sure you turn on interpolation also for the artificial gravity. I ran this test as outlined above. It works.

OMG thank you so much! This has annoyed me countless times that i have just accepted that no matter how big the mass, my rigid body woulden’t fall any faster. Until now, thanks so much!

Works for me! Thanks!

For anyone still looking for this, check this out: Unity - Modify Per-Object Gravity of Rigidbodies in Unity [2023 UPDATED] - YouTube