(16-04-2024, 01:57 AM)Nightfall Wrote: Hello,
I just sent you the profiler data file via email. Please let me know if there is anything wrong with it.
best regards,
Hi,
Took a look at your profiler data. No wonder it's slow, you're updating physics
17 times per frame:
This is the hallmark of
death spiraling, which happens when:
A) your
timestep is too small.
B) your
max allowed timestep is too high.
C) there's something else causing physics to be extremely slow, which in turn forces Unity to update physics multiple times per frame (up to the max allowed timestep) to try and catch up with rendering.
First step is to look at your project's time settings, and making sure that max allowed timestep is set to a small multiple of the timestep. For instance if you're using 0.02 seconds as the timestep, your max allowed timestep should be 0.04-0.06. This will allow a maximum of 3 (0.06/0.02) physics updates per frame.
Zooming the profiler into one step reveals that more than 90% of the time is spent on collision detection and response. The actual cloth simulation takes less than 5% of the time:
So my guess is either you have tens of thousands of contacts being generated, or you have a extremely complex collider (possibly your body MeshCollider) in the scene. Keep in mind that MeshColliders are really, really costly and that
distance fields are almost always a better option.
Also be mindful of your solver's
collision margin and continuous collision detection settings. These determine how many contacts are generated for each particle, if you use a large collision margin or full continuous collision detection, more contacts will be generated and as a result, collision detection/response cost will increase.
As a last note, it sounds like you're trying to add garments on top of a body/mannequin and rely purely on collisions for them to stay in place. This is NOT how character cloth is made in games since it is a brute-force, hugely costly solution. You can't even have deformable MeshColliders in Unity without rebuilding them every frame, this alone can tank your frame rate. Character clothing relies on
skin constraints (or similar approaches) in all engines.
kind regards,