Blender import in Unity, how to generate correct mesh collider?

jtth picture jtth · Jan 28, 2019 · Viewed 8.6k times · Source

unitycapture

How to get/generate a proper mesh collider in Unity using a model exported from Blender (.obj/.fbx)?

This is my second day using Blender and I'm hitting a roadblock. I've tried fiddling with the Rigid Body Collisions, i.e., setting "Shape" to Convex Hull and "Source" to Final/Deformed (Blender docs specify that these two settings capture modifiers), I've tried "Generate Colliders" inside Unity and the mesh collider always comes out as above. A box.

How to assign mesh collider to the exact mesh? I started with a circle and used a boolean modifier to create the cutout. Desire is to have the mesh collider around the mesh exactly, meaning no collider on the cutout. How to do this?

Answer

Julxzs picture Julxzs · Jan 28, 2019

Make sure you have a Mesh Collider component on your object with the correct mesh set. Watch out for the convex parameter for flat objects, as it can sometimes fail and give you a box collider instead.

example screenshot

Edit:

I just noticed you said you were using a RigidBody, which means you need to have Convex set. A solution to this is to make a second mesh in Blender with a third dimension to it, then set the flat one on the Mesh Filter and the one with thickness to the Mesh Collider.