Intro to Unity Physics — Part 1 Rigid Body

Marc Hewitt
3 min readMay 6, 2021

--

While an Unreal Engine game, it makes a good point.

Unity and most modern game engines have a strong base physics system. This base system is great for most games as then you don’t need to license an expensive middleware like the Havok physics engine or code your own.

First, A Big Concept
Using Game Physics
Doesn’t Require a Math Degree

I bring this up as a lot of junior designers and programmers get scared away from the topic thinking they’re going to need to re-learn years of mathematics.

Physics in games is a deep topic, but unless you are coding a physics engine, you do not heavy math. Your in-game physics will never be 100% scientifically accurate, and that is ok.

Most games chase fantasy and sci-fi topics and just plain fun. Look at Portal where you can fly through essentially wormholes at huge velocity straight into a wall and be fine, that has “fake” physics and it’s better for it.

Physics in games can really just come down to fiddling with settings till it feels right.

My favorite example of this is below. They used a simple Sphere Collider with physics materials to make an amazingly fun driving mechanic!

Rigidbody Component

The Rigidbody component is the main component that allows you to interact with the physics system. This is how you apply gravity, collisions, joints, or physics materials. You can read about it fully here on Unity documentation.

Inspector screenshot

Most of these are self-explanatory from drag, mass, and use gravity. But some are not that obvious

Interpolate — None vs Interpolate vs Extrapolate: In Unity’s own words “Try one of the options only if you are seeing jerkiness in your Rigidbody’s movement.” — not too helpful luckily we’ve got the unity forums where someone did a great write-up on Unity Answers. Overall though this option is basically telling the physics engine how to try to calculate the physics better.

Collision Detection: This lets you set how frequently the physics engine should check collisions. Discrete is good enough for most things but sometimes you need the other options to trade performance for more accurate physics.

Constraints let you freeze a position or rotation, the most basic use is making sure your 3d characters don’t topple over due to physics!

What isn’t obvious though is the “Is Kinematic” checkbox.

Rigidbody “Is Kinematic” setting

This is confusing at first but this is a very powerful checkbox. Activating “Is Kinematic” basically is saying “this is a physics object, but don’t apply physics directly to it”.

The main beginner use case is a moving platform. You want it to be a physics object, as you want the player to land on it and be moved by it “physically” with physics. BUT you don’t want it where the force of the player landing on it causes it to spin out of control. So you’d make the moving platform “Is Kinematic” — have physics, but don’t take any in.

Fixed Update

The last piece of knowledge you must know is about, FixedUpdate()

Fixed Updates work like Update() but are run at “Fixed” times. You can configure how often they run in Unity and as developers we can rely on this for certain calculations. We need this as Update() will run as fast (or as slow) as the computer will allow it. Which can be a little wonky when dealing with physics-based math equations.

This can be a whole article on its own but for the simple explanation know to put Physics code in FixedUpdate as that’s just the way Unity’s Physics Engine is set up to run.

In Part 2:

In the next part on physics, we’ll cover the main reason to use them — Colliders and Triggers.

--

--

Marc Hewitt
Marc Hewitt

Written by Marc Hewitt

An Austin TX Unity3d Developer with a unique background in marketing, design, & software development leading digital web agencies to success for the past decade