Learn How to Get Non-Convex Collisions on Dynamic Objects in Unity
Johann Hotzel shared how he created the MeshColliders tool, explaining its purpose, how it works, and the different ways it can be implemented.
Introduction
My name is Johann Hotzel, and I work professionally as a Software Engineer in the financial sector. Outside of work, I've spent several years deeply involved in game development, with a strong focus on real-time physics simulation.
That interest eventually pushed me beyond Unity's built-in systems. I started building custom physics simulations from scratch, including GPU-based solvers for cloth, soft bodies, and fluids, which gave me first-hand insight into both the strengths and limitations of real-time physics engines.
A while ago, I released an open-source Unity library called Unity Simple Physics, which provides lightweight implementations of ropes, cloth, and soft bodies. The guiding philosophy was deliberately simple:
- Minimal authoring effort
- Clear, easy-to-understand systems
- Seamless integration into existing Unity projects
- Maximum reuse of Unity's built-in rigid bodies, joints, and colliders
The motivation behind this was frustration. Many modern physics solutions are powerful, but also complex, difficult to customize, and challenging to maintain, especially for developers who want practical physical behavior without delving into research papers and complex optimization pipelines.
Non-Convex Collisions
While working on the soft-body implementation, I ran into a fundamental limitation of Unity's physics system: Dynamic MeshColliders must be convex. For soft bodies, this is a serious issue. As meshes deform, they often become strongly non-convex, and Unity's convex hull approximation quickly breaks down. The result is collision behavior that feels wrong:
- Objects collide too early
- Visible geometry penetrates colliders
- Interactions lose physical credibility
After researching existing solutions, I was largely dissatisfied. Many options are commercial assets, costing up to $70, while still offering limited flexibility. At the same time, it became clear that this is a problem many Unity developers run into sooner or later. That realization led to this project.
Design
The goal was not to enable true non-convex collision, which would be expensive, unstable, and largely incompatible with Unity's rigid body pipeline.
Instead, the goal was to provide:
- Robust composite collider approximations
- Based on Unity's built-in collider types
- That works with dynamic rigid bodies
- Can be baked in the editor or at runtime
- And keep the codebase small, readable, and maintainable
Rather than relying on a single technique, the project explores multiple composite collider approximation strategies, each with different trade-offs between accuracy, stability, and performance. These approaches evolved iteratively:
- Surface-based sampling
- Solid volume approximation
- Spatial mesh decomposition
True non-convex collision detection for dynamic objects is computationally expensive and notoriously hard to keep stable in real time. Unity's restriction to convex MeshColliders exists for good reasons. Although motivated by non-convex collision problems, the system can be applied to a wide range of mesh types, not just strictly non-convex geometry.
In practice, complex collision shapes must be simplified. Rather than implementing a custom collision pipeline, this project deliberately builds on Unity's standard, built-in collider types and physics system. Instead of forcing a single "best" solution, the project provides multiple composite collider approximations, allowing developers to choose the approach that best fits their use case.
Surface Approximation: Poisson Disc Collider
The Poisson Disc Collider approximates collisions along the surface of a mesh rather than its full volume. Using Poisson disk sampling, points are distributed evenly across the mesh surface while enforcing a minimum distance between samples. This avoids clustering and produces a uniform distribution.
Each sampled point generates a SphereCollider, Unity's cheapest and most robust collider type. To reduce visual artifacts, sample points can optionally be inset slightly along the triangle normal, preventing colliders from visibly protruding beyond the mesh surface.
Strengths:
- Fast and stable
- Cheapest collider type
- Suitable for runtime rebaking
Best suited for:
- Organic or irregular meshes
- Soft or rounded collision behavior
- Deforming or dynamically changing geometry
- Cases where surface contact matters more than interior volume
Because it only represents the surface, this method is not ideal for solid objects, which motivated the next approach.
Solid Volume Approximation: Voxel Collider
The Voxel Collider approximates the entire interior volume of a mesh. A 3D voxel grid fills the mesh bounds, and each voxel center is tested using a point-inside-mesh check based on ray–triangle intersections. Every voxel inside the mesh generates a BoxCollider.
BoxColliders are among Unity's most stable and efficient collider types, making this approach extremely reliable for dynamic rigid bodies. To reduce collider count, an optional greedy merge step combines adjacent voxels into larger boxes while preserving the overall shape.
Strengths:
- Very stable under heavy physical interaction
- Efficient collider type
- Works well in physics-heavy scenes
Best suited for:
- Solid objects
- Performance-critical collision scenarios
- Cases where stability matters more than surface precision
The main drawback is resolution dependency: low voxel resolutions can appear noticeably blocky, especially around curved surfaces, while high voxel resolutions significantly increase the number of BoxColliders and therefore the overall physics cost.
Spatial Mesh Decomposition: Decomposition Collider
The Decomposition Collider operates directly on the original mesh geometry. The mesh is divided into spatial regions using a 3D voxel grid. All triangles overlapping a voxel cell are grouped and converted into a separate convex MeshCollider.
Each resulting collider represents a small, localized mesh that is often convex, or at least close enough to be a good approximation of the original non-convex shape.
This approach sits between the previous two:
- More geometric fidelity than voxel boxes
- Better approximation than a single non-convex MeshCollider
Best suited for:
- Large or detailed meshes
- Cases where closer geometric accuracy is required
Performance depends heavily on voxel resolution and mesh complexity, making this approach best suited for editor-time baking rather than frequent runtime updates.
In my observation, many non-convex meshes can already be approximated reasonably well using a relatively small number of decomposed MeshColliders, providing a good balance between accuracy and collider count.
Conclusion
All three approaches are approximations rather than exact replacements for true non-convex collisions. Each comes with its own trade-offs, but together they cover a wide range of practical, real-world use cases.
The main goal of this project was to provide simple, transparent, and flexible tools that integrate cleanly with Unity's existing physics system. For developers running into Unity's non-convex collider limitations, these techniques offer practical alternatives without relying on costly opaque third-party solutions.
It has been especially rewarding to see that just a few days after release, dozens of users reported that the project helped solve real problems, and that feedback from real-world use cases has already shaped several upcoming improvements. The project is fully open source, with further refinements and extensions planned based on community input.