I've been experimenting with the physics in unity and they seem to run great...with one exception. When I load up my scene on my phone that has a lot of stacked boxes it runs at about 2-3 FPS for 10-20 seconds before it settles down and goes up to a smooth frame rate.
After it settles I can start blowing up the stacks and throwing particles around and the framerate stays smooth. Does anyone know a way to speed up the rigidbodies settling process?
2 Answers
2
How many objects are you talking about?
When a PhysX simulation starts virtually everything is in an active state until the resolver can decide if things are stable or not. Once the engine decides an object is in a stable position it can put it to sleep and it doesn't have to check to see if it is colliding against anything. Lots of objects will unfortunately always have this upfront cost if you add them all to the simulation at the same time and they can all potentially move.
You might be able to add objects with colliders only and then add rigidbodies dynamically when they collide with things. I don't know the details of how that would work in Unity.
You might want to check if your objects are really "precisely" stacked by looking at the size and position numbers, instead of just checking visually. If you are just slightly off, things will move on start.
I'm talking something along the lines of 40-50 blocks precisely stacked.
– anon23814272