Physics (Rigidbody, Colliders) In Unity

Last Updated : 4 May, 2026

Physics makes games feel real. Without physics, objects would pass through each other, nothing would fall, and there would be no collisions. Unity provides two main components for physics i.e Rigidbody and Colliders.

Rigidbody

Rigidbody is a component that adds physics properties to a GameObject. It allows the object to be affected by gravity, forces, and collisions.

  • Mass: How heavy the object is (heavier objects push lighter ones).
  • Drag: Air resistance (higher drag slows object faster).
  • Angular Drag: Resistance to rotation.
  • Use Gravity: Whether object falls down.
  • Is Kinematic: Object moves by script only, not physics.
  • Constraints: Freeze position or rotation on specific axes.
Rigidbody
Rigidbody In Unity

Rigidbody.AddForce (Realistic Movement)

This method applies force to an object, creating smooth acceleration instead of instant movement.

Example:

C#
using UnityEngine;
public class ApplyForce : MonoBehaviour
{
    public float forceAmount = 10f;
    private Rigidbody rb;
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            rb.AddForce(Vector3.up * forceAmount, ForceMode.Impulse);
        }
    }
}

Output:

using-addforce-movement
Rigidbody.AddForce

ForceMode Options in Unity

  • Force: Applies a continuous force over time. The object's mass affects how much it accelerates.
  • Impulse: Applies an instant force in a single frame. Commonly used for jumps or explosions.
  • VelocityChange: Directly changes the velocity instantly, ignoring the object's mass.
  • Acceleration: Applies continuous acceleration over time, ignoring the object's mass.

Colliders

Colliders define the physical shape of an object for collisions. They are invisible but determine when objects touch each other. Types of Colliders:

  • Box Collider: Rectangular shape (walls, crates)
  • Sphere Collider: Round shape (balls, planets)
  • Capsule Collider: Pill shape (characters)
  • Mesh Collider: Exact shape of model (complex objects, expensive)
  • Terrain Collider: Ground and landscapes
Colliders-In-Unity
Colliders In Unity

Collision Detection

When two objects with colliders touch, Unity calls collision events. At least one object must have a Rigidbody.

C#
using UnityEngine;
public class CollisionHandler : MonoBehaviour
{
    // Called when collision starts
    void OnCollisionEnter(Collision collision)
    {
        Debug.Log("Hit: " + collision.gameObject.name);
    }
    // Called every frame while colliding
    void OnCollisionStay(Collision collision)
    {
        Debug.Log("Still touching");
    }
    // Called when collision ends
    void OnCollisionExit(Collision collision)
    {
        Debug.Log("Stopped touching");
    }
}

Triggers

Triggers detect when objects enter an area without physical collision (no bouncing or blocking). Enable by checking Is Trigger on any collider.

C#
using UnityEngine;
public class TriggerHandler : MonoBehaviour
{   // Called when something enters the trigger zone
    void OnTriggerEnter(Collider other)
    {
        Debug.Log("Entered zone: " + other.gameObject.name);
    }

    void OnTriggerStay(Collider other)
    {
        // While inside the zone
    }
    void OnTriggerExit(Collider other)
    {
        Debug.Log("Exited zone");
    }
}

Common uses for triggers:

  • Collecting coins or power-ups
  • Checkpoint zones
  • Damage areas (lava, pits)
  • Door opening zones

Use Cases

  • Player Jumping: Use Rigidbody + Collider and apply AddForce() with Impulse for jumping.
  • Collecting Coin: Use a Trigger Collider and detect collision with OnTriggerEnter(), then destroy the coin and update score.
  • Bouncing Ball: Use a Sphere Collider with a Physics Material (high bounciness).
  • Player Pushing Objects: Both player and objects should have Rigidbody + Collider for realistic interaction.
  • Bullet Hitting Enemy: Bullet uses Rigidbody + Collider, and collision is handled using OnCollisionEnter() on the enemy.

Common Mistakes in Unity Physics

  • Missing Rigidbody on moving objects breaks proper physics and collision handling.
  • Using Mesh Collider on moving objects hurts performance; prefer simple colliders.
  • Moving objects via Transform bypasses physics; use Rigidbody methods instead.
  • Trigger won’t work unless “Is Trigger” is enabled on the collider.
Comment
Article Tags:

Explore