Basic Introduction to Physics in Unity

Objective: To help explain the basic understanding of the Unity physics system if you are new to Unity.

Unity has built in Physics engines which enables objects to be controlled by forces that exist in the real world. E.g. Gravity, acceleration, velocity, mass , drag etc.

Adding a Rigidbody component to the game object will place that object under the control of the Unity physics engine. So far I haven’t added any Rigidbody components to my game objects but let’s have a look at what happens when I do:

No Rigidbody component attached:

No Rigidbody attached — Player game object stands still

Rigidbody component attached:

Rigidbody attached
Rigidbody attached — Watch the player game object fall when the game starts

Tip: There are Rigidbodies for both 2D and 3D. 2D works in a similar way but the forces are applied to the X and Y axis only. If you accidentally add the wrong Rigidbody to your game and you have an existing collider already attached, it should prompt you with a warning that you cannot add this. E.g. I have an existing Box Collider 2D on my player and when I go to add the 3D Rigidbody I get this warning:

Conflicting collider and Rigidbody warning for 2D and 3D

Useful Links:
https://docs.unity3d.com/ScriptReference/Physics.html
https://docs.unity3d.com/ScriptReference/Physics2D.html
https://docs.unity3d.com/2020.1/Documentation/Manual/class-Rigidbody.html
https://docs.unity3d.com/2020.1/Documentation/Manual/class-Rigidbody2D.html

Aspiring Unity Game Developer with a passion for bringing code to life!