3

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?

jtth
  • 876
  • 1
  • 12
  • 40

2 Answers2

4

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.

Julxzs
  • 737
  • 1
  • 7
  • 21
  • Oh. I was using Convex to view the collider. How silly. It was correct and I didn't even test it with simple printouts. Thank you much. – jtth Jan 28 '19 at 14:52
4

In importing a .obj or a .fbx, select the asset. make sure you have generate colliders selected.

Here I have imported an FBX into unity, but there are no colliders.enter image description here

Sellect the asset, and turn on generate colliders if you want a collider around the mesh:

enter image description here