Physics Engine Integration and Collider Setup
Incorrectly configured colliders are one of the most common yet unnoticed problems in Unity projects. Character falls through floor at high speed, bullets vanish without hitting, physics objects jitter on static surface. Causes almost always lie in basics: wrong collider type, missing Continuous collision detection, incorrect layer setup.
Collider Types and When to Use Each
Unity offers six primitive colliders: BoxCollider, SphereCollider, CapsuleCollider, MeshCollider, WheelCollider, TerrainCollider. Plus 2D analogs.
MeshCollider is the main problem source in inexperienced hands. Convex MeshCollider works with Rigidbody correctly but limited to 255 polygons. Non-convex can't apply to dynamic objects at all: Unity warns but doesn't block, behavior is undefined. For characters and projectiles always use primitives; MeshCollider only for static level geometry.
CapsuleCollider is optimal for characters (vertically), projectiles (horizontally). Two parameters: radius and height. Typical mistake—character capsule tuned per VisualMesh, not gameplay needs: too wide capsule makes character "fatter" than appearance and doesn't fit narrow passages.
SphereCollider is cheapest compute-wise. For projectiles, grenades, small items—preferred over CapsuleCollider if shape allows.
Layer Matrix and Physical Interaction
Physics Layer Collision Matrix (Edit → Project Settings → Physics → Layer Collision Matrix) determines which layers interact. Incorrectly built matrix causes:
- Projectiles hitting own team
- Trigger zones reacting to environment, not just player
- Enemies pushing each other on clumping
Correct structure for typical game: Default, Player, Enemy, Projectile, Environment, Trigger, Debris. Projectile interacts with Player, Enemy, Environment—but not Trigger, Debris, other Projectile. Trigger doesn't interact physically with anything—only OnTriggerEnter.
When using Physics.Raycast, Physics.OverlapSphere and similar—always pass LayerMask explicitly. Without mask, cast checks all layers including invisible UI colliders and trigger zones, returns unexpected hits.
Collision Detection Mode and Tunneling
By default Rigidbody uses Discrete collision detection: object position checked at FixedUpdate start and end. If object moves faster than object_size / fixedDeltaTime units per second, it can "jump through" thin geometry—tunneling effect.
Bullet diameter 0.1 units at 50 m/s travels 50 * 0.02 = 1 unit per FixedUpdate. Wall 0.5 units thick gets skipped. Solutions:
-
Rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuousfor dynamic objects that can tunnel through statics -
CollisionDetectionMode.ContinuousDynamicfor objects that can tunnel through other dynamics - For very high-speed bullets—use
Physics.RaycastorPhysics.SphereCastinstead of physicsRigidbodyentirely: more reliable and performant
Continuous mode is CPU expensive. Apply only to fast projectiles and characters—not all objects.
PhysicsMaterial and Friction Tuning
PhysicMaterial (Physics Material asset) sets dynamicFriction, staticFriction, and bounciness. Combining two materials of contacting objects happens via frictionCombine and bounceCombine rule (Average, Minimum, Multiply, Maximum).
For character on Rigidbody: PhysicMaterial with dynamicFriction = 0, staticFriction = 0, frictionCombine = Minimum. Without this character slides on walls, gets stuck on edges, unexpectedly brakes on inclines.
For bouncing objects: bounciness = 0.6, bounceCombine = Maximum. At bounceCombine = Average, ball thrown on surface with bounciness = 0 won't bounce—even if ball itself has high value.
Compound Colliders and Optimization
Complex object shapes are described by multiple primitive colliders on child objects—compound collider. One Rigidbody on parent manages the whole physics unit. This is cheaper than MeshCollider and more accurate than single BoxCollider.
For vehicles: separate BoxCollider for body, bumpers, wheel arches. WheelCollider is specialized component for realistic suspension behavior; not a normal collider and doesn't participate in standard OnCollisionEnter events.
Timeline Guidelines
| Task | Timeframe |
|---|---|
| Basic collider tuning + Layer Matrix | 1–2 days |
| Vehicle physics (WheelCollider, suspension) | 3–7 days |
| Destructible objects system (fractured meshes + Rigidbody) | 1–2 weeks |
| Custom physics solver (no PhysX) | 4–8 weeks |
Common Setup Mistakes
Collider overlaps Renderer mesh—character visually passes through wall but physics blocks invisible barrier. Monitor collider/mesh boundary match.
OnCollisionEnter doesn't fire—one object is kinematic Rigidbody or StaticCollider without Rigidbody. OnCollisionEnter requires Rigidbody on at least one object. For static level geometry, OnTriggerEnter on trigger zones suffices.
Physics objects jitter in place—solver iteration count too low or object under competing forces. Increase Edit → Project Settings → Physics → Default Solver Iterations from 6 to 10–12 for complex scenes.





