Mesh collider not matching mesh

Hello, what am i doing wrong? why doesen’t mesh collider work for me on this mesh? it isn’t align to the outlines of the mesh?

1 Answer

1

Modern game engines usually only allow convex collider shapes for performance reasons. The asset pictured is not convex.

Unity is unusual because it does allow non-convex colliders… but doesn’t run full collision tests on them. Specifically, they won’t collide with other mesh colliders.

From the Colliders Overview manual page:

Also, a mesh collider will normally be unable to collide with another mesh collider (ie, nothing will happen when they make contact). You can get around this in some cases by marking the mesh collider as Convex in the inspector. This will generate the collider shape as a “convex hull” which is like the original mesh but with any undercuts filled in.

In your screenshot, we’re seeing a convex hull because you’ve enabled the “convex” checkbox.

Do you really need that level of collision detail? In most circumstances, you won’t. In the unlikely case that you do, you have the option of creating a compound collider, which is a group of colliders acting together.

Again, from the same manual page:

Any number of [colliders] can be added to a single object to create compound colliders. With careful positioning and sizing, compound colliders can often approximate the shape of an object quite well while keeping a low processor overhead. Further flexibility can be gained by having additional colliders on child objects (eg, boxes can be rotated relative to the local axes of the parent object). However, you should be sure that there is only one Rigidbody and this should be placed on the root object in the hierarchy.

Rutter you should become my new personal assistant.