Hello. I read documentation and see what it’s NOT reccomended to move colliders WITHOUT rigidbody. But i look at profiler and see that when i add rigidbody component at object - physics chart grows up.
My friend tested moving huge amount of static colliders and discovered what with rigidbody component FPS decrease.
And so question: why it’s not recommended to move static colliders?
If this is 2D then the rule is even clearer, don’t move a collider in any way other than modifying the Rigidbody2D it is attached to i.e. use its API to set the pose/velocity etc. If you ignore this you’ll end up with the collider being recreated each time you do so which is expensive for more complex colliders such as PolygonCollider2D, CompositeCollider2D or TilemapCollider2D.
The bigger question is why would you want to move a Static collider after all it’s supposed to be Static i.e. non-moving. If you want to move it then use a Kinematic and that should not be a problem. Adding a Rigidody2D doesn’t create some massive overhead to be avoided. Why make it hard for yourself?
If you absolutely must have it Static and want to move it then add a Rigidbody2D and set its BodyType to Static. You can then set its position.
In the 2D physics engine, colliders live in Rigidbody2D space so if you modify a collider position directly its geometry has to be recalculated. If there’s a Rigidbody2D there then only the Rigidbody2D pose is changed. Of course, this is talking about you modifying the Transform but you should NEVER do that and if it moves in physics then ALWAYS do it via the Rigidbody2D.
Does it work if you ignore what I said above? Well yes because the physics team have to ensure that devs doing all sorts of things at least get expected behaviour but this isn’t to say it gives you the best performance.
In short, if it’s physics and it moves, it should be you driving a Rigidbody2D directly which then drives the Transform for you. Colliders are attached to this so they go along for the ride.