- Home /
Kinematic rigidbodies, colliders and performance
Hello all, I am trying to get clarification on a question I asked some time ago about colliders and performance. I got some different answers the first time around that seemed to conflict with each other (that might be because I didn't explain things well).
My game consists of a bunch of objects that are constantly moving. The background graphics are all hittable and they are constantly moving from right to left. I'm not using any physics - just directly manipulating the positions of transforms. Because there is no physics, I use kinematic rigidbodies for collision detection.
When I originally asked about colliders, I was told that I don't need rigidbodies on both objects that would collide - only on one of them. So I removed a bunch of rigidbodies, and now, only my bullet objects have kinematic rigidbodies. So for example, when a bullet hits a background, I have:
moving bullet: collider with kinematic rigidbody
moving background: collider only (turning it into a static collider)
My question is: would this not create a performance hit? The documentation states: "In general, you should not reposition static colliders by changing the Transform position since this will impact heavily on the performance of the physics engine".
The backgrounds don't need to move as a result of the collision - they are always moving regardless of whether or not they have been hit with a bullet.
So I am confused - I removed rigidbodies, but do I need to re-add them?
My original post is here: http://answers.unity3d.com/questions/512467/are-my-kinematic-rigidbodies-slowing-my-scene-down.html
Many thanks in advance for all answers and insights!
Answer by Halfbiscuit · Oct 13, 2015 at 09:02 AM
I believe when it says static colliders it means objects with colliders and the static variable ticked. Moving an object when it is marked as static means the physics has to redo some calculations.
Moving a collider when the object is not marked as static should not impact performance.
Edit: Seems I was wrong (static variable has no relevance to physics) and according to this answer moving a collider without a rigid body can cause a performance hit.
Thanks for the reply. I'm not sure what you mean by the "static variable" though?
Unity doco defines a static collider in this way:
Colliders can be added to an object without a Rigidbody component to create floors, walls and other motionless elements of a scene. These are referred to as static colliders
The static setting is in the top right in the inspector.
Looking at that link, it doesn't look like setting an object as static impacts collisions or physics - more to do with rendering, lighting, navigation, etc. In any case, none of my objects are non-moving, and none of them are ticked as static.
Your answer
Follow this Question
Related Questions
Will disabeling a static collider have the same performance hit as moving it? 1 Answer
How to check if 2 collisions are on the same objects ? (is player on the same ground than enemy?) 2 Answers
Complex collision layers 1 Answer
Gameobject not detecting collison from other Box Collider 2D [SOLVED?] 2 Answers