Strange physics sleep behaviour causing lag, involving LinearVelocity

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.

5 Likes

Hi @stuart2202, thanks for posting!

Could you please make a repro that demonstrates the issue? Specifically, could you make one with the “old” and “new” behavior with steps on how to reproduce what you’re observing?

It seems like the network ownership of the ship is flickering between the client and server. You should only see the parts highlighted as red if they are awake and simulated by the client. There was a recent change with how we assign ownership, I’m curious if this is related.

Thanks!

1 Like