13-05-2021, 01:27 PM
(This post was last modified: 13-05-2021, 01:29 PM by josemendez.)
(13-05-2021, 01:07 PM)VincentAbert Wrote: Hello,
Let's say I have a level which only features ropes in one or two rooms. Trying to mitigate all my performance overhead, I would like to disable simulation when not needed, what is the best way to do that ?
I tried disabling the updater and solver, and activating them when the player enters a trigger, but it causes a lag spike, probably because of some initialization. What would be the best way to go about this ?
Thank you,
Vincent.
Hi Vincent,
Disabling the solver would be the best option. This is what the solver does internally when you uncheck "Simulate when invisible": it disables itself when outside of any camera frustum, and re-enables when it is visible.
There should not be much of a spike when disabling/enabling the solver (could not reproduce any spikes in any of our test scenes at least), disabling a solver just stops calling its internal update methods. No initialization or data juggling takes place when enabling/disabling. Could you share a profiler screen capture of said spikes?
Note that if you are using the Burst backend, async JIT compilation is enabled by default in-editor, which means that all jobs will be compiled at runtime when first called. This will result in a large spike when enabling a solver for the first time. You can disable this in Unity's Burst menu. Also, it's disabled in builds.