# How can I apply a mesh collider in Unity to an entire imported model rather than a single piece?

I have a series of models from Blender I'm importing to Unity as .blend files and I need mesh colliders applied to each one.

What I'm finding is that with any model that is constructed of multiple primitives, applying the mesh collider to the object is unsuccessful. The mesh collider can't find the mesh. Unity seems to treat each shape inside the model as a separate object. I've even noticed that the Unity editor will allow me to select a single piece of a model and drag it away if I'm not careful. This is unexpected behavior and somewhat alarming.

I've discovered that if I apply a separate mesh collider to each individual piece inside the model, the colliders will find the sub-meshes and the collision detection will work. My primary concern at the moment is that this is monotonous. For example, if I have the following model of a road intersection, then I'll need to individually select each of the seven pieces and create a mesh collider for each one.

How can I apply a mesh collider to the entire model in one move?

UPDATE:

Based on some feedback and some thoughts on my own, I'm redesigning the road pieces to simply be solid road on the bottom with the sidewalks on top. This way, I'll only need one collider for the bottom, for now (if I don't care about testing collisions with the sidewalk edges yet).

I'm hesitant to merge the meshes into a single mesh at this time, though, since I'm potentially not done modelling street pieces yet. This also doesn't address the long-term question of what to do in the final version of the game.

Unity primitives have automatic collision detection, but simulating hills this way and still having the pieces meet seamlessly is difficult. They also won't do curved surfaces as far as I know.

I'd rather not use box colliders, since that will involve a lot of painstaking zooming in and tweaking of tiny values to get them perfect. It also seems that box colliders will only rotate with a model and not to a model that's already sloped.

What I'm trying to avoid is spending almost as much time messing around with the colliders as I did modelling these bits in the first place.

Sticking with the mesh colliders is looking like the best option for now, since most of these shapes are simple, 6-sided objects and it's only a couple of clicks to add a mesh collider to each shape. It sounds like if I do it this way, it might be smarter to keep the meshes un-merged, since I would then be using a mesh collider on a concave object.

• Note that the road piece you've shown can be well represented by convex colliders or even primitives (a box in each corner plus one for the base). If you were to make a single mesh of this and wrap it with a single mesh collider, it would need to be concave, which is much more expensive to process physics interactions on. So although it may be tedious, it might ultimately be better for your game's performance and stability to make these colliders piece by piece. – DMGregory Mar 13 '18 at 11:39
• @DMGregory, the piece-by-piece method is what I'm currently doing, but with mesh colliders. Most of the road sections are sloped or angled and the problem with box colliders is that they can't be rotated (as far as I can tell). The rough draft of the city was done with primitives, but they're very difficult to get lined up smoothly once they've been rotated a few degrees, so I'm taking this modular approach. I'm not sure what you mean by a "single mesh", but I'm still fairly new to modelling. – Nightmare Games Mar 13 '18 at 16:39
• Those individual pieces you can move around are single meshes. The larger tile object you've called a "model" is just a group containing multiple child mesh objects as exported by Blender. You can add your own child objects with box colliders to rotate them any way you need. – DMGregory Mar 13 '18 at 16:52

However it is possible to have a box collider and have it rotated. Assuming that you create a road mesh that is flat, create a box collider and attach it to the road. Now if you place your road mesh on a scene (moving it around, rotating or scaling it) the box collider does the same. This is what I'd recommend.
• @NightmareGames perhaps you could try adding multiple colliders, like one box and two spheres, and move them around depending on your mesh? – TomTsagk Mar 14 '18 at 14:19
• @NightmareGames no, I mean to take a single road mesh (one that has bumps or is curvy as you said) and add 2-3 colliders to it, maybe 3 box colliders or 1 box and 1 sphere collider, that they roughly take the shape of the deformed road mesh. – TomTsagk Mar 15 '18 at 9:59