- Home /
Extending a mesh collider/Other issues using mesh collider
Hello I have a Mesh collider set p on a object that when it falls is supposed to touch the ground but whenever the mesh collider is activated the object falls straight through the ground yet if I use a box collider it works perfectly fine. Also I would like to know if there was any way that I could get the mesh collider to protrude by 1 unit from the actual object.
Answer by shadowpuppet · Jul 18, 2017 at 10:03 PM
Mesh colliders don't seem to handle collision as well as the other types. When I do use a mesh collider and want it to be bigger than the object mesh I just scale that object mesh up a little ( in a 3D program) and use that for the mesh collider rather than the object mesh
Answer by Bunny83 · Jul 18, 2017 at 10:14 PM
Two non convex mesh colliders can't collide with each other. Non-convex mesh collider should only be used for static colliders that do not move. If you want / need to use a mesh collider on a moving rigidbody you should mark it as convex. Keep in mind that a convex mesh collider will use the convex hull of the mesh and not the actual mesh.
If possible you should use primitive colliders (box, sphere, capsule) on moving objects. Keep in mind that you can use multiple colliders for a single rigidbody.
@Bunny83 Sorry I didn't understand the last bit "$$anonymous$$eep in $$anonymous$$d that you can use multiple colliders for a single rigidbody" do you mean we can have multiple objects and then only 1 needs a rigidbody and the rest don't ? Why does that relate to mesh colliders? Also is there any easy way to set up multiple colliders to create one object or do we have to do it manually?
Yes, you can use several child objects with primitive colliders and a rigidbody on the parent will use them. A rigidbody generally uses all colliders in any child objects. This is called a compound collider. See the middle section on the Rigidbody manual page.
$$anonymous$$eshColliders are quite heavy to compute. Primitive colliders are defined as mathematical volume so it's much easier to calculate intersections. The collider of an object usually doesn't need to be too detailed. $$anonymous$$eep in $$anonymous$$d that they just handle collisions. The user never "sees" them.
Note that $$anonymous$$eshColliders have quite a few limitations. As already mentioned non convex mesh colliders can only be used for static geometry (without a rigidbody). Convex mesh colliders are limited to 255 triangles. In most cases a few primitive colliders are enough.
Even most FPS games which might use something like a mesh collider for the world, they usually use a more simplified collider to avoid edge cases. So stairs might be covered by a simple ramp collider to avoid getting stuck. Here are two cases from the game Doom3: Tris / Collision and Tris2 / Collision2
Your answer
Follow this Question
Related Questions
can ContextMenu pass arguments into a method? 1 Answer
I Accidently Deleted My Editor File In The Assests What Do I Do? 1 Answer
MeshCollider is not getting updated when adding vertex to mesh 1 Answer
AddComponent(MeshCollider) not working on Android/iOS 0 Answers
Cutting mesh colliders; Does Unity do culling automatically or do I make my own code? 2 Answers