[PhysX] Fix Inaccurate Convex Mesh Collider Precision
Solution
Unity 2019.4.x - Unity 6.3.x
Published 14 days ago
When applying a convex Mesh Collider to a complex geometry, the resulting collision hull often forms a simplified, enclosing convex shape that ignores concave features, leading to inaccurate collision detection that does not precisely match the visual mesh.
Achieve high-fidelity collision by using Convex Decomposition to break complex geometry into multiple simple convex child colliders.
To achieve more precise collision detection for complex objects that require convex colliders, it is recommended to perform Convex Decomposition on your root object to create multiple, simpler convex sub-meshes. Each of these sub-meshes should be created as a separate child GameObject of your root object. This strategy allows for the aggregation of several smaller convex collision shapes, which together can form a more accurate representation of the object’s overall physical boundaries than a single, large convex hull.
- Divide your root object into several simplified sub-meshes using a 3D modeling tool or a Convex Decomposition utility.
- Import the resulting meshes as child GameObjects under your root object.
- Add a
Mesh Collidercomponent to each child GameObject. - Enable the
Convexproperty on everyMesh Collider. - Remove the
Mesh Rendererfrom child objects to ensure only the visual mesh of your root object is visible.
Additional Tips:
- Ensure the
Rigidbodyis placed on your root object; Unity automatically combines child colliders into a single compound collider. - Use the
Cooking Optionson theMesh Colliderto optimize how the physics engine processes the mesh data. - If your root object is dynamic, remember that
Mesh Collidercomponents must have theConvexflag enabled to collide with otherMesh Collidercomponents.
Related Posts Haven't quite found a solution to your problem? We think these posts might help you.
Content inspired by a Unity discussion post.