- Home /
Increase Gravity?
So, I have objects that have the rigidbody component, and I'm letting let falling down. However, I want to increase the speed they fall down, and I want to be able to control the speed in the script. Can someone plz help?
Answer by RadioactiveTechnologies · Nov 22, 2014 at 02:03 AM
Edit -> Project Settings -> Physics -> Gravity. You can then edit this in your script and use it like:
Physics.gravity.x = gravitySpeed;
verticalVelocity += Physics.gravity.x;
//In this example you may as well use gravitySpeed instead of Physics Gravity.
Note that this is in C#.
This is an O$$anonymous$$ answer though it doesn't quite follow the laws of physic. With a normal gravity of 9.81 m/s^2 verticalVelocity += Physics.gravity.x;
makes the speed of an object grow by 9.81 every update which is a huge increase.
Simple fix: verticalVelocity += Physics.gravity.x * Time.deltaTime;
Sorry guys, I meant to add the Time.deltaTime, and I actually thought I remembered doing it. But apparently I didn't. But thankyou for clarifying this for the user.
Answer by NoseKills · Nov 22, 2014 at 02:05 AM
You can either set the global gravity in Edit->Project Settings->Physics (2D)
Or if you need per object variations in gravity, do what gravity does, which is add a force to every rigidbody in FixedUpdate.
public float gravity;
void FixedUpdate () {
rigidbody2D.AddForce(Vector3.down * gravity * rigidbody2D.mass);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613172141im_/https://answers.unity.com/themes/thub/images/avi.jpg)