Unity Physics: Mesh Colliders

Jared Amlin
Nerd For Tech
3 min readJul 30, 2024

--

If you need a geometrically accurate and easy to apply colliders, look no further than the mesh collider. Mesh colliders are arguably going to be your most expensive collider depending on the number of vertices in your object, so just something to be aware of when potentially bypassing the use of a primitive or compound collider.

If you try to run Unity while a mesh collider is not Kinematic or Convex, you will get this error in the console.

Convex

If you make your mesh collider convex, Unity will make a new collider based on the shape of the model. This collider will be a simplified version of your model. This is the setting you want to use for non-static objects that need realistic physics behaviors.

The Mesh Filter holds the Mesh that will be used for the convex collider. This mesh does not have to be the high-poly mesh that your model is using. It is commonplace to use a low-poly version of your model as the mesh here for the collider to generate from, rather than the mesh of the higher poly-count model.

Here you can see the low-poly mesh made by the convex mesh collider.

Here you can see how much higher poly the actual model is compared to the generated convex collider. The cooking options are where you can change the settings that are impacting the created convex collider. When your mesh collider is not convex, you will double the amount of vertices, but your collider will be the exact shape of your object.

Cooking Options

Cook for Faster Simulation is generally better left on, unless you need to sacrifice some performance for a more accurate simulation.

Enable Mesh Cleaning will reduce the amount of vertices when creating the collider.

Weld Colocated Vertices will weld together close or overlapping vertices.

Use Fast Midphase is only used for PC builds and provides better simulations.

Kinematic

A Kinematic rigidbody is great for static objects, being gravity and other physics simulations will be ignored, while still providing physics based collisions.

The example below shows how the kinematic mesh collider is fit tightly to the mesh so the spheres can roll around in the top. You can also see how it does not fall with gravity unlike the convex mesh collider on the nearby barrel.

I hope this helps you in your collision based journey and thanks for reading!

--

--

Jared Amlin
Nerd For Tech

I am an artist and musician, that is currently diving headfirst into game development with C# and Unity3D.