Basic Physics Components in Unity

Introduction to Unity Physics

In this article we will briefly cover the 3 basics of the Unity physics engine. Unity enables us to control objects by the forces of physics (engine). You can adjust the Physics values for you project under:
Edit > Project Settings > Physics

Project settings Physics

Rigidbody

By adding a Rigidbody component to an game object means the Unity engine will apply physics to it. (Physics means extra calculation for your game so unless you need it don’t add it.)
Some features included are:
A larger “Mass” means it’s less affected by objects with a smaller mass and the other way around.
“Drag” is for air resistance.
“Use Gravity” determines whether an object is affected by gravity or not.

Rigidbody component in the Inspector
Laser without gravity and with gravity

Collider

Colliders are used for Unity to detect collisions between objects. A Rigidbody component is needed for BOTH objects for collisions to happen.
Add a collider just like any other component from the Inspector.

Add Sphere Collider component

There are many types of shapes for Colliders. Like Box, Capsule, Mesh, Sphere, Terrain and Wheel.

Sphere Collider in the Inspector

With the “Edit Collider” button you can edit the the edges of an object where you want the collision to occur.

Edit Collider

Trigger

Triggers are also collision, but without a ‘physics collision’. The physics component gets disabled on the component. The objects just pass through each other. For example you want to detect if a car has passed over a finish line you can use a invisible trigger. Another example is picking up coins or power ups. Scripting allows us to detect when an object enters or exits the trigger object. A Rigidbody component is needed for ONE of the objects for triggers to happen.
To enable trigger on an object just check the “Is Trigger” box:

Optimization

Important to remember is that calculating physics uses resources. Try to only apply physics and interactions between objects where needed. No need to apply physics on a wall that doesn’t move the entire game.

Next up: Scripting Collisions

In the next article Collisions and Triggers will be covered.

--

--

--

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Optimize your IT budget with Cloud computing

How to make sure Kubernetes autoscaler not deleting the nodes which run a specific pod

#100DaysofCode Chapter 7 ~ Mobile First Websites

Kubernetes Service Discovery with Serf

Five Tips to Help You Transition from College into Software Engineering

A dismayed looking calico cat with her ears folded back

Kubelet service is activating. But kubelet is not starting

Takeaways from DevTernity 2021

Why End-to-End Testing May Save Your Mobile App

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tristan Engel

Tristan Engel

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.

More from Medium

Basics of Optimization in Unity

How to Jump in Unity

Modelling Time in Unity

Building a Modular Ducking System