- Home /
Active rigidbodies and number of Contacts
Hi there Uniteers. In the attempt of increasing the performance within our game, I noticed our Physics.simulates eats up 14% of our performance (1.51 ms)
In order to reduce this, I looked into the Physics profiler and noticed that in our game we have:
85: Active Rigidbodies
0: Sleeping Rigidbodies
130: Number of Contacts
800: Static Colliders
49: Dynamic Colliders
The problem is we are not using any physics within our game. All our NPCs have an attached rigidbody due to the fact that if you move a collider without a rigidbody this will create overhead. All rigidbodies have been marked with "IsKinematic", which I believed would put all the rigidbodies into sleep mode.
Am I missing something completely fundamental here? I have tried using rigidbody.Sleep() without succese.
Are your NPCs moving? Because if they are moving they will not sleep. According to the documentation: "There are two variables that you can tune to make sure your rigidbodies automatically fall to rest: Rigidbody.sleepVelocity and Rigidbody.sleepAngularVelocity. Those two variables are initialized to the sleepVelocity and sleepAngularVelocity variable defined in the Physics $$anonymous$$anager (Edit -> Project Settings -> Physics)"
See: http://docs.unity3d.com/Documentation/Components/RigidbodySleeping.html
They are actually not moving when the player is not nearby, but we are currently using $$anonymous$$ecanim, and it tends to move the transform slightly. I'll look into this, thanks for the advice. I'll report back.
Experience have proven to me that it may be hard to entirely eli$$anonymous$$ate the static collider problem that you describe. Even if you feel 100%, sure that nothing is moving objects that lack rigidbodies, check the profiler CPU Graph for any nested expensive collider move entries. It will say something like "delayed cost".
Answer by Freaking-Pingo · Oct 30, 2013 at 08:32 PM
I never really figured out what went wrong in this situation, but my solution to this was simply to disable the collider on the same gameobject that had the rigidbody. In this way there rigidbody could "Sleep".