Capsule vs Box Colliders

Quite simply, which one is more expensive?
I have a scene with about 10000 static colliders, they can approximately be boxes or capsules so its not too much of an issue which one I choose. Though I haven’t thoroughly profiled it, comparing the two, my eyes seemed to tell me that capsule colliders were performing quicker but logically i think boxes should be quicker.

Anyone know for definite which it is?

Many thanks

5 Likes

Well I decided to post some results from some testing.
All tests were done on an intel core2duo 3ghz imac with no rendering, just physics.

Static colliders seem to have such a minimal impact on performance, Upto 60,000 and beyond of all different colliders were causing no noticable effect on the frame time (<3ms)

So I tried testing dynamic colliders instead, much more challenging.

Remember this is just physics, your renderer would bottleneck way before reaching 2500 individual objects.

Dynamic Tests:
500 Colliders
Capsule 2.1ms
Box 2.6ms
Sphere 2ms

1000 Colliders
Capsule 5.6ms
Box 5.8ms
Sphere 2.9ms

1500 Colliders
Capsule 16.1ms
Box 20.5ms
Sphere 4.8ms

2500 Colliders
Capsule 453-481ms
Box 490-520ms
Sphere 190-233ms

So there you have it, across the board capsule actually beats box but not by a huge amount, and sphere obviously kicks everyones ass.

57 Likes

Buried in the dust and no reply. Wow, this is really important stuff.

4 Likes

yep - good info…

sounds quite reasonable

  • sphere collider → 1 Vector
  • capsule collider → 2 sphere colliders + their distance vector
  • Box collider → no clue how it’s done :wink:
4 Likes

Is this still true? Wow, what awesome info. I’ve had it all wrong and thought Box was the most efficient.

4 Likes

I just tested this in Unity 5 RC2 on an old android Galaxy Note

Test was 300 cubes in a blender (pictured) with either box, sphere or capsule colliders, with discrete collisions.

Sphere: 11-12 FPS
Capsule: 5-8 FPS
Box: 2 FPS

So box is really expensive

Nice physics upgrade in Unity 5 though :slight_smile:

9 Likes

Interesting read. :sunglasses:

People who would expect the boxes to be faster aren’t considering the possibility that the boxes are rotated, I imagine.

I’m curious - is it faster if all of the boxes have fixed rotation, or does Unity not recognize that / have some way of being told that so it optimizes accordingly?

I guess I’m just being silly. Premature optimization is the root of all evil, and it’s easy enough to swap between the different colliders later on.

wow this is what im looking for
i plan to change all my chars from box collider to capsule, but afraid of the impact on performance
turn out that capsule is better than box :smile:

thanks for trying this @anon_37040379 !

1 Like

Guys, please. Just stop.

You will find much greater performance hits from the actual physics and collisions. If things aren’t touching, you can have far more. If some things are sleeping, you can have far more. Your fixed update rate affects performance, and layers are important for performance. It’s not just about which collider might be a tiny bit quicker.

While choosing a collider is important, bigger gains are obtained from what you do with them.

1 Like

Started wondering, too. Thanks for the tests!

@hippocoder

But that doesn’t mean he isn’t right. I have 500 + colliders on my scene, and since its a 2.5D side scroller, a lot of collisions are happening to tell the objects to do different things depending on where they are relative to the camera. So this info is really useful. Any little inch you can get when you deploy for mobile, is important.

Unless I’m missing something.

1 Like

well, yes. But any primitive collider, you’ll be finding that if its playable or not comes down to layers and what you’re doing with them… if its mesh collider then it’s a different story, those things are quite slow

It is still useful fundamental information, no need to shoot the posters down for it.

That said, hippocoder does have a point. Also, capsules might be more efficient, but generally take much longer to stabilize as they will tend to roll, whereas a box will stop moving once the bounce has settled and go to sleep. Physics might be cheaper but they will calculate for a longer time in many cases.

4 Likes

Great and important read , thanx for it
is there a way to find similar data on 2D colliders ?

1 Like

Anyone excited about the first post should definitely read @hippocoder 's and @DarthDisembowel_1 's posts.

thinks for the information…

Thanks

Really nice test, thank you

How do you test that?
maybe you used profiler, but I want to know how can I test it again?