xxxxxxxxxx
// Per-GameObject gravity change
class MyGameObject : MonoBehaviour {
private RigidBody _rb;
public float gravityMultiplier;
public void Start() {
_rb = GetComponent<RigidBody>();
}
public void FixedUpdate() {
_rb.addForce(gravityMultiplier * Vector3.down, ForceMode.Force);
}
}
// Global gravity change:
// Edit > Project Settings > Physics > Gravity
// then change the vector at the top.
xxxxxxxxxx
// Four times as strong
Physics2D.gravity = new Vector2(0, Physics2D.gravity.y * 4);
// Half the strength
Physics2D.gravity = new Vector2(0, Physics2D.gravity.y / 2);