- Home /
Does collider size affect performance?
Situation 1:
There are two box colliders, both static. One is of size 1 x 1 x 1 and the other is 10000 x 10000 x 10000 in size. Will the large one cause lag?
Situation 2:
Same setup, but they now both have now have a non-Kinematic rigidbody with mass one. Will the larger one lag?
Situations 3 & 4:
Same as situation one, but using mesh colliders. One is scaled to 10000x its normal size. Will the larger one lag?
No it won't.
What does affect performance are, light and the polycount of a mesh.
Instantiating a mesh collider with custom scale at runtime might be slow.(Afaik) So try too avoid that.
Answer by zach-r-d · Aug 01, 2015 at 09:58 PM
It's hard to say if any of those situations individually would cause lag to appear where previously there was none. As for whether it will affect performance, the answer ultimately depends on the underlying implementation of the physics engine. More specifically, it depends on the spatial acceleration strategy/data structure being used. With no spatial acceleration (i.e. n-squared collision detection, where every object checks every other object for collision), it wouldn't matter, but Unity/PhysX certainly does something smarter. But regardless of the exact spatial partitioning strategy used (whether it's an octtree, kd-tree, or otherwise), the fact is that the larger a collider is, the more things there will be that need to check if they are colliding with it. So in that respect, yes, collider size will affect performance. Making the collider use a rigidbody (making it dynamic) will be an additional hit, as will making it a mesh collider.
Your answer
Follow this Question
Related Questions
Is there ANY possible way to use a mesh collider(without convex) with a rigidbody? 1 Answer
Anyway to make my object not fall through the floor without convex? 0 Answers
Why doesn't my mesh collider collide while a capsule or cube collider works fine? 2 Answers
Stop rigidbody from moving after it falls on another rigidbody 1 Answer
Workaround to Non-Convex mesh colliders with non-Kinematic RigidBodies? 1 Answer