Recently I’ve been working on overhauling a buoyancy system that I made. In the old system, the buoyancy was provided by a VectorForce constraint, a LinearVelocity constraint, and an AngularVelocity constraint. Thanks to an improved understanding of physics and coding, my new system uses a VectorForce and a Torque. It works (almost) perfectly, except from the fact that it caused much lowered frame rates on clients.
In my use case, these forces act upon a single assembly with upwards of 10000 parts. While attempting to find the cause of the lag, I noticed some odd behaviour with the physics sleep visualisation. In my new system, when the player contacted the assembly, it was highlighted red despite being network owned by the server. I checked on the server and verified that network ownership was being held by it and not switched over. In the server view, it appears red.
This does not happen in the old system. The ship remains unhighlighted at all times. In the server view, it appears highlighted red, as expected.
After some debugging I was not able to work out the cause but I was able to find a work around. By applying a LinearVelocity constraint with a max force of 1 to the ship, the performance issues suddenly went away completely. The strange sleep highlighting on the client stopped happening.
In some instances, this nearly doubled my FPS. I am under the impression this behaviour is not intended due to the sharp performance decrease for seemingly no reason.
Expected behavior
The physics performance should be high even without a LinearVelocity attachment.