Rotation Jitter on Rigidbodies caused by GImbal Lock(?) through Networking

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Myziam

Hey. So I’ve been working on a physics based sandbox game that has Multiplayer (testing, not final release), and I’ve noticed a seriously strange and damaging bug with the physics engine.

If an object falls on it’s side so the X rotation axis reads as -90, and it has values on the other axises (such as 26 for Y), if it gets a force applied on it the other values will suddenly rotate by about 180 degrees and then immediately switch back to what they should be. This doesn’t render on the host because I presume the physics engine has some slight interpolation or smoothing, but the numbers do jitter if you view it through the editor or print it.
This wouldn’t be an issue if it was a Singleplayer game, however I mentioned this is Multiplayer. The clients don’t calculate any physics so it updates the position and rotation objectively. Since the values on the host are jittering, and it sends that over to the clients that read the value and update objectively (no smoothing) there’s a horrible jitter on all physics objects. I believe this has something to do with Gimbal Lock since if I lock the X Angular axis, there can be hundreds of objects that will not jitter ever.

Is there anything I can do about this? Preferably with as little extra code as possible but I’m up to do anything to fix this.
I tried adjusting the Physics Framerate, lowering it and raising it and it still jitters. I don’t know what the Physics Jitter Fix option does, but changing its value doesn’t seem to affect anything, and I also tried changing physics engines from GodotPhysics to Bullet, nothing is affected.

Video of the issue in action

Thank you for reading, I hope I can fix this. I heard Godot 3.2 is going to fix some physics bugs so hopefully this gets ironed out. but I still need this fixed right away.

EDIT: I have a feeling this is actually due to the physics engine calculating in Quaternions (I think), but converting it to a Vector3 to make it easier to manipulate. If I could have access to the lower level engine values like the Quaternion it’s using for rotation (I think) then I might be able to properly reconstruct this on the other end?
Just throwing ideas out there.