- Home /
Collision Colliders - Box or Mesh for Terrain
So, I'm currently grayboxing a test level that I'm making, and I'm not sure how to go about doing the collision detection for the level. The level is being made with solid brushes (think Valve Hammer Editor) and I'm deleting faces that aren't visible to the user.
However, this means that my terrain, which is modeled out of boxes, becomes paper-thin when I get rid of unused faces. If I recall correctly, colliders that are incredibly thin can be passed through when it comes to physics calculations.
What would be the best way to remidy this problem? Should I manually sculpt and add thick box colliders along the level (particularly the ground), use mesh colliders, etc? I know mesh colliders are available, but wouldn't this problem still exist if I used them as well?
Answer by $$anonymous$$ · Apr 08, 2013 at 12:26 PM
You can still model your own collider. When you put a MeshCollider component you will see on the inspector that basicly it just reuse your terrain model as collider. But you can change it to another model. So when you export your 3d model from your 3d app make also a collision one with the same pivot position. The collision model doesn't need any texturing just export it as is it, then when you add the Mesh Collider component change the collision model to your custom one.
Ooh forgot about that. This would work well on more complex areas of the level, and use boxes for the simple portions. Do you know how much of a cost there is on using a mesh collider with a simple mesh vs a regular box collider? Id eager more complex meshes (that still work under the mesh collider limit) have more of an impact compare to simple ones
Well ofcourse $$anonymous$$esh Colliders will be always more expensive performance wise compared to the primitives one, but with more complex eometry you have to forcely use them sooner or later, making a terrain with box collides is just overkill other than the fact that you would need hundreds of them so performance wise you may still be going the same direction as with a mesh one.
$$anonymous$$y advice is to plan ahead what you need, like for example if you do an FPS and need the projectiles to hit perfectly he shapes of complex models you may need to use mesh colliders, or you would see impacts in midair.
Also another thing you mst know, two rigidbody mesh colliders can't collide eachother unless one of them is Convex shape. You can thick the convex shape in the mesh collider inspector. So for Static use non convex shapes, for rigidbodies thick the option.
Your answer
Follow this Question
Related Questions
My object falls through terrain. 8 Answers
Best collision detection method? 2 Answers
Ship and terrain collision.Need help. 1 Answer
Collision Problem - Terrain collider remains flat after raising or lowering it 0 Answers
Object Flies into Air Upon Collision, or goes through hill depending on isKinematic settings 1 Answer