- Home /
For flat mesh, is there a performance difference between box vs mesh colliders?
big difference? little? thanks, I appreciate any help.
Answer by Bunny83 · Jan 01, 2013 at 02:56 AM
Primitive colliders are easier to calculate than MeshColliders. So yes, there is a difference.
MeshColliders are fine for static meshes. But for dynamic objects / rigidbodies you should use Primitive colliders or compound colliders made up of primitive colliders.
If you need Rigidbodies with MeshColliders you should make them convex in order to collide with other meshcolliders. However MeshColliders don't work with flat geometry because a RB collider always needs to have a volume. A flat mesh like a plane doesn't have a volume.
But seems that a box collider contains 12 triangles so in cases of simple mesh like triangle or rectangle box would be more expensive, I am just wondering.
@tomekkie2: Box colliders don't contain any triangles at all. A mesh collider is always more expensive because it has to compute arbitrary meshes and can't do any shortcuts or optimizations. Since a box collider uses relatively simple math to compute the box, it's quite a bit faster than computing a mesh that happens to be in the shape of a box.