Overview of Physics in Unity

by Michael Sacco Published January 10, 2024
The cover for Overview of Physics in Unity

Without physics, there is no game development. Physics in Unity is the building block for game development in Unity. It defines the interaction between game objects. Physics in Unity is provided by the Unity Physics Engine.

This is a series on Unity Physics. We recommend reading the series in order.

  1. Unity Physics
  2. Unity Collision Detection
  3. Character Controller and Input Systems
  4. Rigidbody Mass in Unity
  5. How to add Friction to a Rigidbody
  6. Cylinder Collider in Unity
  7. Box Collider in Unity
  8. Box Cast in Unity
  9. Sorting Layers
  10. Get the distance between two objects
  11. How to normalize a vector

Key Concepts in Unity Physics Engine

In this article, you will learn about key concepts in the Unity Physics Engine.

Colliders

This indicates when characters collide with each other. For collisions to occur, each character must have a RigidBody component. There are several types of colliders. They include:

To add a collider to a Unity game object, click on Add Component from the inspector window, select Physics, and choose the collider you want to use from the drop-down.

πŸ“„ Resources:

Triggers

Triggers allow characters to pass through it by disabling physics on the component. That is, characters can enter or exit the trigger. Just like colliders, the characters must have a RigidBody component to move within the trigger. To activate this component, you have to check the Is Trigger checkbox on the collider.

Rigidbody

Now, we have about this particular physics as an essentiality for the above two physics. What is RigidBody itself?The RigidBody component is the component that gives the effect of physics properties to game objects. Physical properties like mass, velocity, drag, and gravity. It has an Is Kinematic checkbox which allows the physics to affect other objects but not itself. There is also an Interpolate select box that checks collisions. You can either choose Interpolate or Extrapolate. Another select box is Collision Detection which checks the rate of collisions. You can choose Discrete, Continuous, Continuous Dynamic, or Continuous Speculative. There is also a Constraints drop-down.

To access this component, click on Add Component from the inspector window, select Physics, and choose RigidBody from the drop-down.

Physics Materials

These are components that control the surface friction and bounciness. They include:

  • Bouncy
  • Ice
  • Max Friction
  • Metal
  • Rubber
  • Wood
  • Zero Friction

Joints

There are different types of joint components in the Unity Physics Engine. They include:

  • Fixed Joint component – as the name implies, this component creates a permanent joint between two game objects.
  • Spring Joint component – this component moves the game objects in a spring-like manner.
  • Hinge Joint component – this component is similar to the previous one but moves the game objects around a pivot.

Scripting

These are functions for interacting with game objects. They include:

  • OnCollisionEnter – to register a collision.
  • OnCollisionStay – during a collision.
  • OnCollisionExit – to exit a collision.
  • useGravity – to enable or disable gravity.
  • AddForce – to add a force in a particular direction.
  • AddTorque – to add a rotational force.

πŸ“„ Resources:

Layers and Collision Matrices

The collision matrix helps determine the relationship between collision layers. It can be found in the Physics Engine settings. To open this, go to Edit in the menu drop-down, select Project Settings, then Physics. The collision matrix will be seen at the bottom of that window.

Conclusion

Apart from the physics components in the Unity Physics Engine listed above, there are others. However, the ones listed above are the basic physics components you need to know to start your game development with Unity.To learn more about the Unity Physics Engine, visit Unity’s official docs here.

Free download: Indie Game Marketing Checklist

Download now

Category

physics

Don't forget to share this post!

Popular assets for Unity

See all assets ->
    Cutting-edge volumetric fog and volumetric lighting with support for transparent materials.
    Volumetric clouds, day night cycles, dynamic skies, global lighting, weather effects, and planets and moons.
    A lightweight procedural skybox ideal for semi-stylized projects.
    Image-based Outlines for 2D and 3D games with variable line weight, color, and displacement options.
    Drag-and-drop ready-to-use ambient, impact, and spell particle effects.
    Per-pixel gaussian blur on your entire screen, part of the UI, or in-scene objects.

Free Indie Game Marketing Checklist

Learn how to make your game successful with this handy checklist.

Download for free