I was watching a video on optimization from Unite 2012. One of the lecturers stated that if a collider ever moves it should have a rigid body attached (since every time a collider without a rigidbody moves a bunch of collision geometry needs to be recalculated).
My question is: If the collider is stationary (i.e. never moves) but you enable/disable it. Does it have the same impact as moving a collider? Should I add a rigidbody and set kinematic to true?
In the scene in question it’s a box collider that prevents items from dropping away. At some point it is disabled, the items drop away (get destroyed when off screen) and then it’s re-enabled.
I really do not like the unity manual guides. I am not very good with studying, and I usually find that their answers/examples only slightly point me in the right direction. There is always the possibility that the answers are outdated for older verions of Unity as well. I am not sure how often they update?
But anyways I believe the problems you are describing only occur when an object is moved with physics. So just enabling and disabling the object, I believe it should be fine as a static object.
This is however an interesting thing I need to consider for my own projects. Is it really that bad to move an object with a collider without a Rigidbody? I did not realize this could cause performance issues thanks for posting this question.
Anyone know more details about this? Seems counter-intuitive that a more simple object would be more performance heavy. Maybe this only applies to AddForce for the PhysX? If it applies to transform.position to even without a rigidbody… then well, I am confused.
And can’t you check the tickbox to determine whether an object is static? It seems they are saying it’s an automatic function?
It is really rare when the Unity manual actually helps me. I find that solving problems based on their examples/answers is usually like banging my head into a wall repeatedly until I happen to hallucinate the right solution.
They should really have more in depth examples and guides for those of us who aren’t “pros”, or “geniuses”.
It almost seems like they want you to have trouble learning this stuff, or they are VERY bad teachers.
I would so no, reason being is as follows:
Each collider that is created static gets copied into the physx engine, this then combines and optimises into a single optimised mass collider routine, so basically they would not be one collider but get grouped so that near calculations can be made to work out which colliders should be tested.
If you enable or disable any of these, unity only tells physx to ignore collisions (in the same way as how layers work and ignore colliders work) but the grouping remains.
However if you create a new one or move a static one, the whole lot gets recalculated…which is really slow.
Ultimately any questions on whats faster, what will affect performance…just write a quite test and check the performance.