Unity Physics Integration: Collider Tuning & Layer Matrix Setup

Our video game development company runs independent projects, jointly creates games with the client and provides additional operational services. Expertise of our team allows us to cover all gaming platforms and develop an amazing product that matches the customer’s vision and players preferences.

From immersive apps to game worlds and 3D scenes

Our dedicated team for VR/AR/MR development, Unity production and 3D modeling & animation — with its own case studies and capability decks.

Visit the dedicated studio
Showing 1 of 1All 242 services
Unity Physics Integration: Collider Tuning & Layer Matrix Setup
Medium
from 2 days to 2 weeks
Frequently Asked Questions

Our competencies

What are the stages of Game Development?

Latest works

  • image_games_mortal_motors_495_0.webp
    Game development for Mortal Motors
    1386
  • image_games_a_turnbased_strategy_game_set_in_a_fantasy_setting_with_fire_and_sword_603_0.webp
    A turn-based strategy game set in a fantasy setting, With Fire and Sword
    926
  • image_games_second_team_604_0.webp
    Game development for the company Second term
    544
  • image_games_phoenix_ii_606_0.webp
    3D animation - teaser for the game Phoenix 2.
    591

Incorrectly configured colliders are one of the most common and subtle problems in Unity projects. We, as engineers with 10+ years of production experience, see it constantly: the character falls through the floor at high speed, bullets vanish without hitting the target, physics objects jitter on a static surface. The causes are almost always fundamentals: wrong collider type, missing Continuous collision detection, incorrect layer settings. Our team guarantees to eliminate these issues turnkey — contact us, we'll evaluate your project.

Why colliders are set up incorrectly?

Unity offers six primitive colliders: BoxCollider, SphereCollider, CapsuleCollider, MeshCollider, WheelCollider, TerrainCollider. Plus 2D equivalents. MeshCollider is the main source of problems in inexperienced hands. Convex MeshCollider works correctly with Rigidbody but is limited to 255 polygons. Non-convex cannot be applied to dynamic objects at all — Unity will give a warning but won't block it, leading to undefined behavior. For characters and projectiles we always use primitives; MeshCollider only for static level geometry.

CapsuleCollider is optimal for characters (vertical) and bullets (horizontal). Two parameters: radius and height. Typical mistake: the character's capsule is sized to the visual mesh instead of gameplay needs — too wide makes the character 'fatter' than it looks, so it can't fit through narrow passages. SphereCollider is the cheapest computationally. For projectiles, grenades, and small items, prefer CapsuleCollider if the shape allows.

How to set up Layer Matrix?

Physics Layer Collision Matrix (Edit → Project Settings → Physics → Layer Collision Matrix) determines which layers interact. An incorrect matrix leads to: projectiles hitting their own team; trigger zones reacting to the environment instead of only the player; enemies pushing each other when grouped. A proper layer structure for a typical game: Default, Player, Enemy, Projectile, Environment, Trigger, Debris. Projectile interacts with Player, Enemy, Environment — but not with Trigger, Debris, other Projectile. Trigger has no physical interaction — only OnTriggerEnter. When using Physics.Raycast or Physics.OverlapSphere, always pass LayerMask explicitly — without a mask, the cast checks all layers, including invisible UI colliders and trigger zones, returning unexpected hits.

Collision Detection Mode: defeating the tunnelling effect

By default, Rigidbody uses Discrete collision detection: the object's position is checked at the beginning and end of each FixedUpdate. If the object moves faster than objectSize / fixedDeltaTime units per second, it can 'jump' through thin geometry — this is the tunnelling effect. A bullet of diameter 0.1 units at speed 50 m/s travels 50 * 0.02 = 1 unit per one FixedUpdate. A wall of thickness 0.5 units will be missed. Solutions:

  • Rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous — for dynamic objects that may tunnel through static objects
  • CollisionDetectionMode.ContinuousDynamic — for objects that may tunnel through other dynamic objects
  • For extremely high-speed bullets, use Physics.Raycast or Physics.SphereCast instead of a physical Rigidbody: more reliable and performant

Continuous mode is more CPU-intensive. Apply only to fast projectiles and characters — not to all objects indiscriminately.

PhysicMaterial and friction tuning

PhysicMaterial defines dynamicFriction, staticFriction, and bounciness. The combination of two materials from contacting objects follows frictionCombine and bounceCombine rules (Average, Minimum, Multiply, Maximum). For a character on Rigidbody: PhysicMaterial with dynamicFriction = 0, staticFriction = 0, frictionCombine = Minimum. Without this, the character slips along walls, gets stuck on edges, and unexpectedly slows on slopes. For bouncing objects: bounciness = 0.6, bounceCombine = Maximum. With bounceCombine = Average, a ball thrown onto a surface with bounciness = 0 won't bounce at all — even if the ball itself has a high value.

Compound colliders and optimization

We describe complex object shapes using several primitive colliders on child objects — a compound collider. One Rigidbody on the parent controls the entire physics unit. This is cheaper than MeshCollider and more accurate than a single BoxCollider. For vehicles: separate BoxColliders for the body, bumpers, wheel arches. WheelCollider is a specialized component for realistic suspension behavior; it does not participate in standard OnCollisionEnter events.

What is included in turnkey physics setup

Stage Details
Audit of current configuration Analysis of colliders, Layer Matrix, PhysicMaterial, and collision detection
Design and implementation Setup of collider types, compound colliders, physics materials
Performance optimization Layer Matrix tuning, reducing draw calls via batching, solver iteration adjustment
Testing Verification for tunnelling, physics stability at different FPS
Documentation and training Architecture description, recommendations for further development

On one recent project, we fixed a character that constantly fell through floors at speeds above 10 m/s. The root cause was a non-convex MeshCollider on the environment and Discrete detection on the character. We replaced the MeshCollider with a set of primitive BoxColliders forming a compound collider, set the character's Rigidbody to Continuous, and adjusted the Layer Matrix to exclude trigger zones from raycast hits. After the fix, the character never fell through, and the CPU overhead increased by only 3%.

Timeline estimates (cost quoted after analysis)

Task Timeline
Basic character collider setup + Layer Matrix 1–2 days
Vehicle physics (WheelCollider, suspension) 3–7 days
Destructible object system (fractured meshes + Rigidbody) 1–2 weeks
Custom physics solver (without PhysX) 4–8 weeks

Typical mistakes and how to avoid them

Collider extends beyond the renderer mesh — the character visually passes through a wall but physically hits an invisible barrier. Ensure collider dimensions match the mesh. OnCollisionEnter is not called — one of the objects is a kinematic Rigidbody or a StaticCollider without Rigidbody. OnCollisionEnter requires a Rigidbody on at least one object. For static geometry, OnTriggerEnter on trigger zones is sufficient. Physics objects jitter in place — solver iteration count is too low or the object is under competing forces. Increase Default Solver Iterations from 6 to 10–12 for complex scenes.

Our engineers with years of experience can help you avoid these pitfalls. Order a physics setup — get a consultation and a ready solution.