Unity Physics: Gravity Controls

Jared Amlin
3 min readAug 13, 2024

When it comes to using the physics engine in Unity, gravity basics can go a long way toward achieving a variety of behaviors.

Gravity

I am going be using this sci-fi crate object for this example. It has box collider and rigidbody components.

By default, Use Gravity is enabled on the rigidbody, which will use Unity’s default gravity settings.

The Project Settings > Physics directory will show where the default gravity value is stored. It is a Vector3 variable that applies downward movement on the Y axis.

This Gravity script is attached to the cube object, and has a Vector3 variable with a positive 1 value on the Y axis. Using this value will make objects float upwards with a small amount of reverse gravity.

Physics.gravity is assigned the value of the simulated gravity variable in void Start.

public class Gravity : MonoBehaviour
{
[SerializeField] private Vector3 _simulatedGravity;

// Start is…

--

--

Jared Amlin

I am an artist and musician, that is currently diving headfirst into game development with C# and Unity3D.