Triggers vs Collisions

Unity physics gives you two ways for two objects to meet, and every interactive thing you build this year is one or the other. Pick wrong and your coin pushes the player around the screen; pick right and the whole game feels invisible — which is the point. This is the complete reference for the physics family: pickups, hazards, hitboxes, ladders.

The one-line rule

A trigger asks "did we overlap?" A collider asks "can we occupy the same space?" — triggers are for events (you entered a region); collisions are for physics (you cannot walk through a wall). Everything else follows from that.

TriggerCollider (non-trigger)
Is Trigger checked?YesNo
Does physics resolve the overlap?No — objects pass throughYes — objects push/stop
Message you receiveOnTriggerEnter2D / Stay2D / Exit2DOnCollisionEnter2D / Stay2D / Exit2D
Handler argumentCollider2D (no contact points)Collision2D (with contact points)
Needs a Rigidbody?At least one object in the pairAt least one object in the pair
Your game uses it forcoins, potions, ladders, hitboxes, promptsground, walls, spikes, enemy contact

Enter, Stay, Exit — the three moments

Every overlap has a lifecycle, and Unity calls one method per moment:

The classic bug pair: Enter-only handlers mean "one event per bump" (a coin is collected once — but standing inside a hazard deals damage only once). Stay handlers mean "an event every frame" (a continuous hazard — but a coin collected in Stay would try to collect itself 60 times a second and crash on the second, because Destroy already removed it).

You will meet a hazard that genuinely needs both in 4.4, when the enemy attacks you. Damage on contact handles the first bump; damage while you remain in contact is what stops you simply standing inside an enemy forever. The moment you use Stay, you owe it a cooldown — because Stay fires every frame, and without a cooldown it drains your whole health bar in about a twentieth of a second.

The tag check — the first branch of every handler

A handler fires for EVERY overlapping object — walls, other enemies, the player, your own projectiles. The first line of almost every handler you write this year filters with CompareTag:

Every handler you write this year has the same three-part shape: filter (which object did we touch?), guard (is everything I need actually there?), then act and clean up (change the number, remove the pickup). You will write that shape four times before the year is out — coin, potion, axe, and damage — and the only parts that change are the tag you filter on and the number you change.

The silent-failure trap: a misspelled tag does not throw. The branch simply never matches and nothing happens, with no error to follow. When a trigger "does nothing," check the tag's spelling FIRST — in both places: the object's Tag field, and the string in your code.

Why pickups are triggers and hazards are colliders

A coin must not shove the player when collected — overlap is an event, not a wall: trigger. A spike is a physical thing you are stopped by or standing on, AND an event when touched — collider, with the damage handler riding on the collision message. The turret's projectile splits the difference, and you will decide this yourself in 3.4: its collider is usually a trigger (a bullet passes through the player's body until it chooses to "hit"), but it dies on contact with whatever you decide should stop it. Note that a bullet also needs a Rigidbody2D before any of this fires — one of the two objects in the pair must have a body, exactly as with the coin.

The settings that break everything

Where you meet each pattern this year

← Unit 2 All docs C# Quick Reference →