Rigid bodies jittering when they are selected in the inspector ONLY!

Hello,

I am struggling with a very strange problem, in my opinion. I have a custom ragdoll with Configurable Joints, and it is pretty stable during gameplay. However, if I select the GameObject containing the Rigid Body + Collider in the inspector, or I select any other GameObject in the scene that also responds to physics, then the limbs connected to my Configurable Joints in the ragdoll start to jitter a lot.

This is a character with a controller placed in the upper-arm.

If I do nothing (jitters a little bit):

If I select one of the GameObject:

I also realized that is jitters when I do other stuff in my computer. For example, if I have a Zoom meeting and I share my screen in parallel, it starts again to be extremely unstable.

Enable Collision and Enable Preprocessing are disabled in all the Configurable Joints. The default number of iterations is set to 20. I honestly do not know what to do more. It looks that it only happens when I increase the load in my Unity scene by interacting with other RBs or when I do external stuff.

Any help would be tremendously appreciated. Thank you!

Are you doing any force calculations by yourself, eg. in the Update() function? If so, are you maybe using Time.deltaTime?

Yes, but all the calculations and interactions with the RBs are being done in FixedUpdate and also with Time.fixedDeltaTime. I just checked and I do not rely on deltaTime for such operations.

However, as you mentioned, it looks like something depends on Time.deltaTime, that is why when the FPS drops, the RBs jitter. I will search again.

Typically, you don’t need to use fixedDeltaTime. If, for example, you have a RigidBody of mass 1 and gravity of [0, -9.81, 0], you can make the rigidbody float in mid-air using rb.AddForce(Vector3.up * 9.81). No scaling by Time.fixedDeltaTime needed.

But that’s just cosmetic. Scaling by fixedDeltaTime won’t cause the behaviour to be different when the visual framerate drops. I’m also pretty sure you scaled something by deltaTime that you shouldn’t have (btw. as @Edy most rightfully keeps mentioning: Time.deltaTime === Time.fixedDeltaTime when called from within FixedUpdate)

Thanks @tjmaul for the answer.

It seems that the code is rather OK, and the issue is this one: Significant editorloop performance drop when only certain objects are selected in the inspector.

It actually describes very well the behavior: I just tried to minimize the Rigid Body info in the inspector and the lag reduces considerably. I am still trying to solve it.

Yep, the (was new) UIElements replacing the IMGUI in the inspector has gone through all sorts of performance issues.

It’s not a physics thing or specifically anything that the rollout there does, it was just the terrible performance of the inspector therefore the editor.

Thanks @MelvMay for your answer. Is there any solution to the problem, or are you aware of a Unity version that does not suffer from this performance issue? The only way I have found so far to completely reduce lag is to leave everything unselected in the hierarchy.

If I were to build the application I wouldn’t mind, but I have to work from the editor so I would be happy to know if there is a solution.

Regards!

I had thought that performance was improved since back then where the post was referring to.

Note that there’s been a bunch of posts about this “blaming” everything from Physics to Audio. Basically anywhere we have a regular update to the inspector required.

The thing is, I’m not a UI or Editor dev so any improvements are not something I would know about. All I know is that when UIElements replaced a lot of the IMGUI in the inspector, draw cost was high then it improved considerably.