- Home /
Rotate static collider, Is it too bad for preformance?
Is it too big of a deal to rotate a static collider using : transform.rotation
every update or should I attach a ridgidbody and use Ridgidbody.rotation/ridgidbody.MoveRotation()
every fixed update?
Answer by Bunny83 · Apr 28, 2016 at 06:23 AM
Well, you have to distinguish between those cases:
moving a gameobject with a collider that is marked static.
moving a gameobject with a collider that is not marked static.
moving a gameobject with a collider that also has a kinematic rigidbody attached.
Case 1 is the worst case possible. It's extremely bad for performance to move / rotate / scale objects which have been marked as static. Static objects are optimised since they should never move or change at all. If you do anyways the engine has to dump all the oprimisation it has done and recalculate it.
Case 2 is not as bad for performance as case 1, but has the same problems. An object with only a collider attached can't detect collisions. Sometimes it might appear that it does work but that's just luck. Only not sleeping rigidbodies can detect collisions. Rigidbodies fall asleep after a certain time of inactivity (not moving / rotating). As soon as you move or rotate it, it will wake up. Even if you move a gameobject with collider but no rigidbody into another object with a sleeping rigidbody, no collision will be detected.
Case 3 is the usual case. Whenever an object with collider is moved and that movement can cause collisions with other objects, you should attach a kinematic rigidbody. Kinematic RBs can't detect collisions themselfs but are able to wake up other rigidbodies in their way. Kinematic RBs can detect triggers though.
Movement is handled different from rotation. While you can move your object simply be changing it's position, rotation is less forgiving. If you want a rotation to correctly detect collisions you should use MoveRotation.