I'm new to Unity. I was wondering what the best workflows were for placing colliders.

I'm going for high performance, and I've heard that mesh colliders aren't as performant as just placing down box colliders. So I assume that placing down a bunch of box colliders everywhere is the best for performance.

This is a pretty frustrating process because it's hard to visualize my box colliders after placing a new one (they only render if they're selected). It's also pretty difficult to tell if I'm lining everything up OK in the world.

Here's a short vid of what I'm doing: clone, move, nudge, repeat, hope that I'm setting up things in a way that is at least sort of lining up with the meshes.

I have a hard time believing that everyone is doing this, so what are people doing?

  • \$\begingroup\$ Those railing segments seem to be repeating. Are they individual prefabs or is the whole environment one mesh imported from a 3d modeling program? \$\endgroup\$
    – Philipp
    Commented Apr 4 at 10:29

1 Answer 1

  1. Whenever possible, add your colliders to prefabs so that you don't have to manually place them in the scene.

  2. For something curved like that railing, you can save yourself a lot of headache by finding the center of the curve and rotating from there. I skimmed the video, but it looks like the railing is almost a complete circle. So you would create an empty GameObject with its center in the middle of the circle (let's call this new GameObject the "container"), and create one box collider as a child of the container. Then duplicate the container and rotate it until the box collider lines up with the next section of the rail. After you have a few containers, you can duplicate and rotate several of them at once. Once you've completed the rail, move all of the colliders into one container and then delete the other (now empty) containers.

Animation of placing colliders around circle Here's an example animation to illustrate the concept from #2. The cyan circle in the middle represents the pivot point around which we are rotating the containers. The yellow boxes are the colliders.

Lastly, trying to optimize too early often wastes a lot of time and effort on the wrong things. I often use mesh colliders with the "convex" box checked (this causes Unity to simplify the mesh used for the collider) and it's never caused performance issues as far as I can recall. You might try using convex mesh colliders on relatively convex objects for now and going back to optimize later if you find that there's a performance problem. Note that if the curved railing is one mesh, you could not use a convex mesh collider for it.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .