Unity: Introduction to Physics

Unity has a powerful physics system built in. In this article I will go through the basics of using this system.

Ian Plumpton
2 min readMay 14, 2021
This is not how lasers should behave…

There are two main elements required for physics in Unity: a Collider and a Rigidbody.

Box collider in the Inspector

When you add a Gameobject to your scene, generally, they come with a collider attached already. For example my cube has a box collider already in place. A Collider registers when an object has collided with another object that contains a Rigidbody element; it also has the ability to collect info on that other object.

The main setting to note here is ‘Is Trigger’. If this is selected, the object attached will continue through the collision but will register the info. If not selected, it becomes a physical collision and the object will physically collide (see my chaotic laser GIF above…)

The second element is the Rigidbody which you will need to add as a component to the Gameobject. The Rigidbody allows an object to collide with another object. Without it, the object would pass through without registering with the opposing collider.

The main option in the Rigidbody to think about for now is ‘Use Gravity’. When checked, this automatically applies gravity to the Gameobject in the Y axis; this is what was causing the whacky behaviour in my lasers.

With ‘Use Gravity’ disabled, my projectiles are now acting as intended.

That’s the basics in the Unity side of these elements. In my next article I will go over how we can access and use them in code to produce game mechanics.

--

--

Ian Plumpton

Software developer in the field of Unity and C#. Passionate about creating and always driven to develop.