- Home /
Which is most optimized collider for road?
I have a lot of road. Should I have the roads as one mesh, or multiple (If using mesh collider)? The roads are all flat, so is there any advantage in using box colliders over mesh colliders?
I think a box collider would work better to your advantage.
Answer by sparkzbarca · Dec 20, 2012 at 07:31 PM
box collider is MUCH MUCH faster.
It has to do with built in shortcut methods of detecting collisions.
For example an object which is greater than half the width of a square from the center of the square is clearly not colliding with it.
2 boxes could quickly be compared for collision this way against eachother.
Meshes dont allow you to make assumptions like a box that allows you to easily define the shape completely based on the center point. Circles/spheres are the next best shape and they are equally defined by there radius.
Now with circles for example once you get close you have to do some harder math to figure out the exact point of collision. But You can instantly discard many possible collisions through fast distance checks.
(meshes do this to for some extent. Thats what bounding boxes are for, but bounding boxes are in fact exactly a box, so box is fastest.
Bounding boxes are the smallest box possible which emcompasses all vertices of a mesh. There used as a shortcut way to test as well.
Still boxes are way faster, followed by spheres, then cylinder/capsule, then the mesh.
thanks, very helpful! Would it be better to use one collider per road chunk, or just one giant collider? And should I leave the road models as chunks or make them as one? Sorry so many questions..
About the other questions, check this similar question (that has not been resolved yec correctly).. http://answers.unity3d.com/questions/374007/large-flat-surface-use-multiple-or-one-box-collide.html
I$$anonymous$$O, One Giant collider would be best, as only one GameObject is needed for the collider, not one for each chunk.
Your answer
![](https://koobas.hobune.stream/wayback/20220613085701im_/https://answers.unity.com/themes/thub/images/avi.jpg)