- Home /
Rigidbody.isKinematic vs. moving a static collider via script
Hello,
I have a question about performance.
Since everything has change with the Unity 5 physics (I am refering to the improved physics performance in Unity 5 in all areas stated in my question). I am wondering what the best practices are for mobile?
Unity 5 states that it has improved performance in both the ability to have more Rigibodies in a scene and in moving static colliders without rigidbodies(This use to be a big problem to process).
Below I will state 2 different scenarios and would appreciate feedback from anybody that might know the correct answer.
Scenario 1) - I have a scene with a 150 Rigidbody objects(all are instances from 4 different prefabs). Only 5 to 10 are in motion at the same time with gravity turned on. The rest have isKinmatic turned on with no gravity but have the potential to move if triggered. If they are triggered isKinematic is disabled temporarily and gravity is enabled temporarily until the object stops moving(then they revert to isKinematic and back to no gravity). All of these objects have a box collider.
vs.
Scenario 2) - Having a scene with 150 collider game objects with no Rigidbody. All of the game objects have the potential to move via script but only 5 to 10 will be in motion at the same time.
Scenario 1 is easier to create. Scenario 2 is more complicated scripting wise. I would like to know is there a big difference between the two scenarios in how heavy the processing is or since I have isKinematic turned on for most of the objects in scenario 1 does this even out the two scenarios?
Thanks in Advance-
I would say you answered the question yourself:
Scenario 1 is easier to handle, use it
Test Scenario 1 before thinking about optimization. Works right out of the box and won't cost that much time for a later switch to 2.
PhysX is highly optimized and calculates motion faster due to the natively compiled code. I'd also suppose it uses data driven design at its core which makes such operations even faster.
Rigidbodies that don't move sleep anyway so there's not even a need for setting them is$$anonymous$$inematic (and the threshold can be tweaked too)
Hope I could give some insights from what I know :)
Your answer
Follow this Question
Related Questions
How do I grab an object without going through it? 0 Answers
Rotating a transform with child rigidbodies 0 Answers
(2D) Can't use colliders when I have a kinematic rigidbody? 1 Answer
Can i Move/Rotate triggers without Rigidbodies? And other collider questions. 3 Answers
Controll squeeze of rigidbody between static collider and kinematic rigidbody. 1 Answer