Physics Collider Optimization in Complex Game Scenes

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.
Showing 1 of 1 servicesAll 242 services
Physics Collider Optimization in Complex Game Scenes
Medium
~3-5 business days
FAQ
Our competencies
What are the stages of Game Development?
Latest works
  • image_games_mortal_motors_495_0.webp
    Game development for Mortal Motors
    663
  • 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
    859
  • image_games_second_team_604_0.webp
    Game development for the company Second term
    490
  • image_games_phoenix_ii_606_0.webp
    3D animation - teaser for the game Phoenix 2.
    533

id: 240 slug: physics-collider-optimization-in-complex-game-scenes title_en: "Physics Collider Optimization in Complex Game Scenes" tags: [vr-ar]

Physics Collider Optimization in Complex Game Scenes

Scene with 800 GameObject, each with MeshCollider by real geometry — PhysX spends 8–12 ms on FixedUpdate only on Broadphase and Narrowphase checks. This half frame-budget on physics alone. In VR where frame budget 11 ms (90 FPS), immediate drop. Collider optimization — one of those tasks where correct architecture from start saves weeks of work later.

How PhysX Spends Time and Where Losses

Physics in Unity passes two stages: Broadphase (fast filter: which objects even close to each other?) and Narrowphase (precise intersection check for filtered pairs).

Broadphase uses AABB-tree (Axis-Aligned Bounding Box). If objects constantly move — tree constantly rebuilds. 200 Rigidbody with isKinematic = false, moving each frame, give constant AABB-tree rebuild. Solution: objects not moving now, switch to isKinematic = true via script — they fall out dynamic tree.

Narrowphase — where MeshCollider kills performance. Intersection check of two arbitrary meshes — O(n×m) by triangles. Character collider against building collider with 50,000 triangles — thousands of operations per Narrowphase. PhysX doesn't support non-convex MeshCollider against MeshCollider in dynamic objects at all — only against Static.

Practical Replacements and Simplifications

Rule one: replace MeshCollider where imperceptible to player. Chair with MeshCollider by real geometry — 200 triangles. Same chair with 2 BoxCollider (legs + seat) — 2 primitives. Collision accuracy 95% of original, cost — 50x less.

For organic shapes (rocks, barrels, cars) set of 3–6 ConvexMeshCollider (convex simplified meshes) works orders of magnitude faster than non-convex and visually indistinguishable. In Unity: MeshCollider.convex = true + simplified mesh via LOD or manual collision proxy creation in Blender.

Compound Colliders — set of primitives as child objects of one Rigidbody. Only way to get "non-convex" dynamic physics without non-convex MeshCollider: several convex pieces = complex shape. For weapons in VR, detailed objects, robots — standard approach.

Collision Matrix (Layer Collision Matrix). In Physics Settings → Layer Collision Matrix disable checks between layers never interacting: Environment vs Environment, UI vs Physics Objects, VFX vs any layer. Each disabled pair — fewer Broadphase pairs. Proper matrix setup reduces active pairs by 30–50%.

Sleep Threshold. Rigidbody sleeps when velocity drops below Physics.sleepThreshold. Sleeping Rigidbody doesn't participate in physics — near-zero cost. Default value (0.005) too low for complex scenes: objects stay active on microvibrations. For VR-scenes without fluid/cloth simulation set 0.1–0.2.

Diagnostic Tools

Physics Profiler in Unity Profiler — shows Broadphase, Narrowphase time, separate SimulateAndCollide, UpdateTriggers. Here visible where losses.

Physics Debugger (Window → Analysis → Physics Debugger) — visualizes colliders in Scene View with color-coding by type (Static, Dynamic, Kinematic, Trigger). Quick identification of unexpectedly heavy colliders.

PhysicsViewer custom Editor Tool — script outputting list of all MeshColliders in scene, sorted by triangle count. Written in 30 minutes, saves hours of searching.

From practice: in VR-trainer for industrial equipment, plant shop scene contained 1200 objects, most with MeshCollider by imported CAD-models (15,000–80,000 triangles each). Physics CPU time — 14 ms. After replacing all static MeshColliders with Convex proxy (auto via Editor script + VHACD decomposition) and disabling unneeded Layer Matrix pairs — Physics CPU time dropped to 2.8 ms.

Work Stages

Profiling. Physics Profiler snapshot, bottleneck identification.

Scene audit. All colliders inventory, classification by type and cost.

Optimization. MeshCollider replacement with primitives/Compound, Layer Matrix setup, Sleep Threshold.

Automation tools. Editor scripts for batch-replacement and validation.

Re-profiling. Comparison with baseline, changes documentation.

Scene Scale Estimated Timeline
1 scene up to 500 objects 3–7 days
Several scenes, 1000–3000 objects 2–4 weeks
Large project with automated tools 1–2 months

Cost calculated after profiling and change scope assessment.