【Unity】Unity 2D Physics Basics: Rigidbody2D and Collider2D

Created: 2025-12-07Last updated: 2026-07-10

Your character tips over on its own, bullets pass through walls, you get stuck on slopes—every classic 2D physics problem has a standard fix. This article covers Rigidbody2D Body Types, choosing the right Collider2D, Is Trigger, and the go-to implementation idioms for 2D platformers.

The places where 2D game physics trips people up are remarkably predictable. Your character tips over from the momentum of landing. Fast bullets pass straight through walls. You get snagged on slopes and tile seams. And every one of these has a standard, well-known fix.

This article covers the heart of 2D physics—Rigidbody2D and Collider2D—from the basics through fixes for the classic problems, up to the implementation idioms of 2D platformers.

Conceptual image of 2D physics: in a clay-style 2D game scene, a character jumps, crates are stacked, and a ball rolls down a slope

What You'll Learn

  • How 2D differs from 3D—the 2D components are a completely separate system
  • The role of each Body Type (Dynamic/Kinematic/Static)
  • Choosing a Collider2D—why Capsule is the standard for characters
  • Is Trigger and collision events (coin pickups, damage zones)
  • Fixes for the big three problems (tipping over, tunneling, jittering)

Sponsored

3D and 2D Physics Are Separate Worlds

Unity ships with two independent physics engines: one for 3D (PhysX) and one for 2D (Box2D). Rigidbody and Rigidbody2D, BoxCollider and BoxCollider2D—they only share similar names. They never interact with each other.

"I added a Rigidbody but OnCollisionEnter2D never fires"—the number one beginner pitfall in 2D is mixing in 3D components. In a 2D game, use only the components with the 2D suffix.

An object with a Rigidbody2D comes under the 2D physics engine's control: it falls with gravity, moves with forces, and collides with other objects. Two differences from the 3D version:

  • Everything happens on the XY plane: There is no movement along the Z axis.
  • Rotation is a single float: Unlike 3D's Quaternion, it only tracks the rotation angle around the Z axis.

Body Type: Three Types, Chosen by Role

A Rigidbody2D's behavior changes dramatically with its Body Type. Choose based on "who moves this object?"

Diagram of the three Body Types: Dynamic is a ball that falls and bounces with gravity, Kinematic is a moving platform that follows a scripted rail, and Static is a wall fixed to the ground
Body TypeMoved byUse forBehavior
DynamicThe physics enginePlayers, enemies, thrown bombs, falling rocksFully subject to gravity, forces, and collisions (default)
KinematicYour scriptsMoving platforms, lifts, enemies on railsIgnores gravity and collision responses; move it with MovePosition() etc.
StaticNobodyGround, walls, immovable obstaclesCompletely fixed. Cheapest to simulate

tips: If you forget to add a Rigidbody2D to static terrain, a lone Collider2D is still treated as a "static object." However, if there's any chance you'll move it at runtime, the correct practice is to add a Kinematic Rigidbody2D—moving a collider without a Rigidbody forces the physics engine to recalculate, which is expensive.

Sponsored

Collider2D: Defining the Collision Shape

A Collider2D defines the physical "shape." To the physics engine, the real body of your object is the collider's shape, not the visible Sprite.

Diagram of Collider2D types: Box = crates and floors, Circle = balls, Capsule = characters (no corners to snag), Polygon = complex terrain—four shapes paired with their use cases
  • BoxCollider2D: Rectangle. Floors, walls, crates—the most versatile and lightweight.
  • CircleCollider2D: Circle. For balls and bullets. Its shape doesn't change when rotating, making it great for spinning objects.
  • CapsuleCollider2D: Capsule. The standard for player hitboxes. The rounded bottom prevents corners from snagging on slopes and tile seams.
  • PolygonCollider2D: Auto-generates a polygon from the Sprite's shape. Precise, but heavier with more vertices—overkill for a character's everyday hitbox.
  • CompositeCollider2D: Merges multiple colliders into one. The classic use is consolidating a tilemap's many BoxCollider2Ds for optimization.

"Capsule for characters, Box (+ Composite) for terrain, Circle for balls"—start with this combination and you won't go wrong.

Is Trigger and Collision Events

Turn on a Collider2D's Is Trigger and the physical response disappears—it becomes a sensor that only detects overlap. Use it wherever you want detection without collision: coin pickups, damage zones, goal lines.

Comparison of collision vs. trigger: with Collision, the character physically bumps into a crate and stops; with Trigger, the moment the character passes through a coin it sparkles as the overlap is detected

In scripts, you receive them through the corresponding pair of events:

using UnityEngine;

public class PlayerController2D : MonoBehaviour
{
    // Detects physical collisions (with response)
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Enemy"))
        {
            Debug.Log("Hit an enemy!");
        }
    }

    // Detects triggers (overlap)
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Coin"))
        {
            Debug.Log("Got a coin!");
            Destroy(other.gameObject);
        }
    }
}

The conditions for these events to fire and how to use Enter/Stay/Exit are covered in detail in the OnTrigger and OnCollision article.

Classic 2D Physics Problems and Fixes

All three problems from the intro can be fixed right in the Rigidbody2D's Inspector.

Diagram of the three classic 2D physics problems and their fixes: tips over → Freeze Rotation Z, tunnels through walls → set Collision Detection to Continuous, looks jittery → Interpolate—each symptom paired with its setting
SymptomCauseFix
Character tips over on its ownDynamic bodies rotate on collisionEnable Constraints > Freeze Rotation Z
Fast bullets tunnel through wallsDiscrete doesn't interpolate between framesSet Collision Detection to Continuous
Movement looks jitteryPhysics runs on the FixedUpdate cycle, rendering per frameSet Interpolate to Interpolate

Freeze Rotation Z in particular is near-mandatory for player characters. A 2D action hero is exactly the kind of object you want "moved by physics, but never rolling over."

Hands-On: A 2D Action Hero That Doesn't Tip or Tunnel

A side-scroller protagonist, a metroidvania double-jumper, a block you roll around in a physics puzzler—the foundation for any "character you control" in 2D is almost always the same three-piece kit. Let's assemble the settings above into a moving character.

Diagram of the three-piece kit for moving a 2D action hero with physics: one character annotated with Rigidbody2D (Dynamic) + Freeze Rotation Z, a CapsuleCollider2D, and a ground check (a short ray at the feet)
  • Rigidbody2D (Dynamic) + Freeze Rotation Z: Moved by physics, but with rotation locked so collisions can't knock it over.
  • CapsuleCollider2D: A rounded bottom that won't snag on ledges or tile seams.
  • Ground check (a ray at the feet): A short downward probe that decides whether jumping is allowed.

With the kit in place, movement and jumping are scripted. The 2D action staple is to overwrite only the horizontal component of linearVelocity (formerly velocity) and leave the vertical to physics (gravity and jump arcs).

using UnityEngine;

[RequireComponent(typeof(Rigidbody2D))]
public class PlatformerMove : MonoBehaviour
{
    [SerializeField] private float moveSpeed = 8f;
    [SerializeField] private float jumpPower = 12f;
    [SerializeField] private LayerMask groundLayer;  // Limit the ground check to the "ground" layer only
    [SerializeField] private Transform groundCheck;   // An empty object placed at the feet

    private Rigidbody2D rb;

    void Awake() => rb = GetComponent<Rigidbody2D>();

    void Update()
    {
        float x = Input.GetAxisRaw("Horizontal");
        // Overwrite only the horizontal; leave vertical (gravity, jump velocity) to physics
        rb.linearVelocity = new Vector2(x * moveSpeed, rb.linearVelocity.y);

        // Jump only while grounded (overwrite the vertical velocity)
        if (Input.GetButtonDown("Jump") && IsGrounded())
        {
            rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpPower);
        }
    }

    // Grounded if a small circle at the feet overlaps the ground layer
    private bool IsGrounded()
    {
        return Physics2D.OverlapCircle(groundCheck.position, 0.1f, groundLayer) != null;
    }
}

Two points matter most here.

  • Horizontal by velocity, vertical by physics: Input overwrites only the x of linearVelocity, passing y through untouched. The physics engine computes gravity and the jump arc for you, so your code only has to "overwrite y at the moment of takeoff."
  • Check the ground from the collider's feet: IsGrounded() uses Physics2D.OverlapCircle from the groundCheck at the feet, looking only at the ground layer. It's the essential check that prevents infinite mid-air jumping (for the Physics2D.Raycast approach, see the Raycast article).

Strictly speaking, forces and velocity should be applied in FixedUpdate (read input in Update, apply physics in FixedUpdate—see the Update vs FixedUpdate article). Get it moving first; split them if jitter starts bothering you.

tips: velocity was renamed to linearVelocity in Unity 6 (see the Unity 6 API migration guide). One-way platforms you can jump onto from below are built with Platform Effector 2D (see Bonus).

Bonus: Good to Know for Later

  • Physics Material 2D: A "material" you assign to colliders, with Friction and Bounciness—slippery ice floors and super balls. It also fixes wall-sticking (holding toward a wall mid-jump and not falling): use a material with Friction 0.
  • Effector2D: A family of components that give colliders special force fields. Platform Effector 2D gives you "platforms you can jump through from below" (one-way platforms) in one step—required knowledge for 2D platformers.
  • Tilemap Collider 2D: For tilemap terrain, the standard combo is Tilemap Collider 2D + Composite Collider 2D. Per-tile colliders get merged, which also reduces seam snagging.
  • Physics update timing: Strictly, forces and velocity belong in FixedUpdate (see the Update vs FixedUpdate article).

Summary

  • 2D physics is a separate system from 3D. Use only the 2D-suffixed components.
  • Choose Body Type by "who moves it": physics = Dynamic, script = Kinematic, immovable = Static.
  • Colliders: "characters = Capsule, terrain = Box, balls = Circle." Overly precise Polygons are expensive.
  • For detection without response, use Is Trigger + the OnTrigger2D family of events.
  • Tipping → Freeze Rotation Z, tunneling → Continuous, jitter → Interpolate. The big three are all solved in the Inspector.

The physics engine hands you believable motion for free. Start your character with the three-piece kit: Rigidbody2D + CapsuleCollider2D + Freeze Rotation Z.