The Mesh Collider takes a Mesh Asset and builds its ColliderAn invisible shape that is used to handle physical collisions for an object. A collider doesn’t need to be exactly the same shape as the object’s mesh - a rough approximation is often more efficient and indistinguishable in gameplay. More info
See in Glossary based on that Mesh. It is far more accurate for collision detectionAn automatic process performed by Unity which determines whether a moving GameObject with a rigidbody and collider component has come into contact with any other colliders. More info
See in Glossary than using primitives for complicated Meshes. Mesh Colliders that are marked as Convex can collide with other Mesh Colliders.
|Convex||Tick the checkbox to enable Convex. If enabled, this Mesh Collider collides with other Mesh Colliders. Convex Mesh Colliders are limited to 255 triangles.|
|Is Trigger||If enabled, Unity uses this Collider for triggering events, and the physics engineA system that simulates aspects of physical systems so that objects can accelerate correctly and be affected by collisions, gravity and other forces. More info
See in Glossary ignores it.
|Cooking Options||Enable or disable the Mesh cooking options that affect how the physics engine processes Meshes.|
|None||Disable all of the Cooking Options listed below.|
|Everything||Enable all of the Cooking Options listed below.|
|Cook for Faster Simulation||Make the physics engine cook Meshes for faster simulation. When enabled, this runs some extra steps to guarantee the resulting Mesh is optimal for run-time performance. This affects the performance of the physics queries and contacts generation. When this setting is disabled, the physics engine uses a faster cooking time instead, and produces results as fast as possible. Consequently, the cooked Mesh Collider might not be optimal.|
|Enable Mesh Cleaning||Make the physics engine clean Meshes. When enabled, the cooking process tries to eliminate degenerate triangles of the Mesh, as well as other geometrical artifacts. This results in a Mesh that is better suited for use in collisionA collision occurs when the physics engine detects that the colliders of two GameObjects make contact or overlap, when at least one has a rigidbody component and is in motion. More info
See in Glossary detection and tends to produce more accurate hit points.
|Weld Colocated Vertices||Make the physics engine remove equal vertices in the Meshes. When enabled, the physics engine combines the vertices that have the same position. This is important for the collision feedback that happens at run time.|
|MaterialAn asset that defines how a surface should be rendered, by including references to the Textures it uses, tiling information, Color tints and more. The available options for a Material depend on which Shader the Material is using. More info
See in Glossary
|Reference to the Physics Material that determines how this Collider interacts with others.|
|MeshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
See in Glossary
|Reference to the Mesh to use for collisions.|
The Mesh Collider builds its collision representation from the Mesh attached to the GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary, and reads the properties of the attached Transform to set its position and scale correctly. The benefit of this is that you can make the shape of the Collider exactly the same as the shape of the visible Mesh for the GameObject, resulting in more precise and authentic collisions. However, this precision comes with a higher processing overhead than collisions involving primitive colliders (such as Sphere, Box, and Capsule) and so it is best to use Mesh Colliders sparingly.
Faces in collision meshes are one-sided. This means objects can pass through them from one direction, but collide with them from the other.
Mesh cooking changes a normal Mesh into a Mesh that you can use in the physics engine. Cooking builds the spatial search structures for the physics queries, such as Physics.Raycast, as well as supporting structures for the contacts generation. Unity cooks all Meshes before using them in collision detection. This can happen at import time (Import Settings > Model > Generate Colliders) or at run time.
When generating Meshes at run time (for example, for procedural surfaces), it’s useful to set the Cooking Options to produce results faster, and disable the additional data cleaning steps of cleaning. The downside is that you need to generate no degenerate triangles and no co-located vertices, but the cooking works faster.
If you disable Enable Mesh Cleaning or Weld Colocated Vertices, you need to ensure you aren’t using data that those algorithms would otherwise filter. Make sure you don’t have any co-located vertices if Weld Colocated Vertices is disabled, and when Enable Mesh Cleaning is enabled, make sure there are no tiny triangles whose area is close to zero, no thin triangles, and no huge triangles whose area is close to infinity.
Note: Setting Cooking Options to any other value than the default settings means the Mesh Collider must use a Mesh that has an isReadable value of true.
There are some limitations when using the Mesh Collider:
Mesh Colliders that do not have Convex enabled are only supported on GameObjects without a RigidbodyA component that allows a GameObject to be affected by simulated gravity and other forces. More info
See in Glossary component. To apply a Mesh Collider to a Rigidbody component, tick the Convex checkbox.
For a Mesh Collider to work properly, the Mesh must be read/write enabled in any of these circumstances:
Optimization tip: If a Mesh is used only by a Mesh Collider, you can disable NormalsThe direction perpendicular to the surface of a mesh, represented by a Vector. Unity uses normals to determine object orientation and apply shading. More info
See in Glossary in Import Settings, because the physics system doesn’t need them.
Updated Mesh Collider limitations in 2018.3
2018–10–12 Page amended with editorial review
Mesh Cooking Options added in 2017.3 NewIn20173
Updated functionality in 2018.1
Updated limitations relating to read/write enabled setting in 2017.3
Inflate Convex Mesh deprecated in 2018.3 because the new convex hull computation algorithm (Quickhull) is more tolerant towards imperfections in the input mesh.
Did you find this page useful? Please give it a rating: