Physics optimization

Hi! I used Profiler to find reason of low FPS in my game. And I seen that about 90-99% of CPU Usage is in Physics (in some moments).

Some more statistics:

  • Active Rigidbodies: 870-930
  • Sleep Rigidbodies (Sleep Velocity - 0.15): about 30
  • Number of contacts: about 3K
  • Static Colliders: about 200
  • Dynamic Colliders: about 1K

I know that there’re a lot of rigidbodies and a lot of collisions in this game, but I can’t remove any rigidbody or subtract the number of collisions. I use ONLY Box Colliders, there aren’t any mesh colliders in my game.

I hope you can help me…

Do some changes in timstep goto edit > project settings > time

Set Fixed TimeStep to 0.01 in Time Manager.

and also change solver iteration count from 7 to 1 in physics setting.

check your objects delete non-sleeping rigid bodies if they don’t needed.

Do you need all those rigidbodies active all the time? I mean you have them in the screen affecting the player?

Did you try tweaking the collision layers and the solver iteration counter?

Without knowing the details of your game I’m not sure if this will work, but in some cases combining multiple box colliders into a single mesh collider can be more effective. This is how Mine Craft works. It doesn’t have thousands of cubes with colliders, it has a single mesh collider that gets updated every time a cube is moved.