I have slow moving gameObjects that are moved exclusively with code. They have colldiers and are never affected by physics in anyway.
Up until now, it was clear that I needed to have a rigidbody2d (mine is a 2d game) attached, flagged IsKiematic, for optimal performance because of the way the physics engined worked internally.
I am aware that Unity 5 has optimized the engine so that there is no longer the performance penalty that was seen prior when moving a collider without a rigidbody.
Still, since I’m obsessed with squeezing out every last possible ounce of performance, especially for mobile, can I get the last word about whether or not there is still a performance gain to be had, no matter how small, with having a rigidbody as opposed to not? Or the other way around?
I’ve search the Internets but have gotten conflicting thoughts, most of them very vague and probably just guesses.
I am aware that Unity 5 has optimized
the engine so that there is no longer
the performance penalty that was seen
prior when moving a collider without a
This applies to 3D physics (PhysX), not 2D physics (Box2D). It’s quite simple; static colliders are called static because they are designed to not move so never ever do so. All static colliders are added (behind the scenes) to a single static body. This means we don’t have a static body for each static collider which, for obvious reasons, is far better however it also means that this single static ‘ground body’ lives at the world origin thus when you ‘resposition’ a static collider, it has to be recreated at the new position you specify. Technically the colliders geometry is transformed to the position but the single static body stays at the world origin. This isn’t normally a problem because nobody should ever move (during gametime) a static collider.
So never move a static collider. You can trust me on this because I wrote the physics code that does it.