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?
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#.
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);
}