- Home /
Why doesn't my mesh collider collide while a capsule or cube collider works fine?
For some reason, when this object has a mesh collider attatched to it, the object falls through the floor upon startup. This doesn't happen with any of the normal colliders. What could be happening?
Ah, thanks. I didn't have the cylinder mesh set to convex. $$anonymous$$aking it convex causes it to collide properly with the ground, which was concave as you suspected.
Answer by nesis · Feb 25, 2014 at 11:25 PM
Complexity of collision geometry can be an issue with mesh colliders. Unity's collision detection works best when mesh colliders are convex - that is, concave meshes can have issues colliding correctly. The cylinder mesh is convex, though, so I suspect the issue is that your ground is a concave mesh collider? To confirm this, see if the cylinder collider falls through a big, flat box collider.
I've converted my comment to an answer - $$anonymous$$d marking it correct so other users can troubleshoot this kind of problem easily? Thanks!
a mesh collider can collide with box collider, but its not working. i cant convert mesh collider to covex, because it has a hole in it. any help with that
Only static $$anonymous$$eshColliders can be non-convex. Dynamic $$anonymous$$eshColliders (i.e. $$anonymous$$eshColliders which are part of a moving Rigidbody) has to be convex. In the past Unity allowed non-convex colliders on rigidbodies, but it actually never really worked properly. So you can not have a concave $$anonymous$$eshCollider on a rigidbody. You would have to split your collider into several convex collider parts or (what would be better for performance) use several primitive colliders to form your concave collision volume.
There are several third party solutions for creating concave colliders out of several convex colliders or primitive colliders.
Apart from the fact that the physics system (PhysX) only supports convex colliders for dynamic objects, it's also limited to max 255 polygons per collider. If you hit this limit for a convex $$anonymous$$eshCollider, see this post
Answer by giano574 · Feb 25, 2014 at 11:36 PM
The floor probably has a mesh collider as well. You can't have two mesh colliders collide in Unity. If the floor is not flat and you can not give it a box collider, you will have to give your object a box/cylinder/etc. collider.
Thanks, but it turns out nesis was correct. Apparently you actually can have two mesh colliders collide in unity, but they can't both be concave.
The truth is, you can have two mesh colliders collide in Unity, if one (or both, can't quite remember) is marked as Convex.
Your answer
Follow this Question
Related Questions
Stop rigidbody from moving after it falls on another rigidbody 1 Answer
Workaround to Non-Convex mesh colliders with non-Kinematic RigidBodies? 1 Answer
How to remove internal triangle/faces when combining mesh 0 Answers
fast collision between a mesh collider and a continuous dynamic rigidbody 1 Answer
Is there ANY possible way to use a mesh collider(without convex) with a rigidbody? 1 Answer