Sleeping Parts system is completely broken, refusing to keep parts with slow-moving constraints awake

This is a bug currently making it difficult to release an update on my over 70 million+ played game.
When you have a part moved by a physics constraint - whether Linear Velocity or Align Position or anything else -
and said constraint has a relatively small (under 0.5 speed) velocity to it…

It just doesn’t work. It literally does nothing but move a foot then stop.
it’s so bizarre, because you’d think, it *has a constraint mover in it, surely it knows it shouldn’t stop?

But, evidently, it sleeps. Forever.

Like, surely a single line of code to check if something has a constraint with velocity in it should prevent this sleeping from happening, on roblox’s end?

Expected behavior

Parts should not be allowed to asleep if they are floating mid-air while un-anchored or have a physics constraint turned on in them

Period. If I wanted this part to sleep I would not leave it floating mid-air, and I would not have left a constraint in it that is literally telling it to move. I do not know why this is happening.

Replication Steps

Open up a new place, put a linear velocity into a part, set it to a low value, press ‘Run’ and watch it do nothing.

13 Likes

Thanks for the report! We’ll follow up when we have an update for you.

5 Likes

Bump because there has been nothing done since this. Parts still go to sleep with slow moving constraints and it is a constant headache since we don’t get any control to manually tell the physics engine to not allow specific parts to go to sleep. As a result we need to resort to hacky methods such as using a script to constantly change a parts velocity to keep it awake. Modules such as AlarmClock were made for this exact purpose.

4 Likes

Yeah it’s incredibly annoying, I wish there was a proper way to wake a part up to have it ready for action that didn’t involve constantly giving it a little ‘nudge’…

1 Like

Any updates? I’m working with a team on a bowling game and it’s bad enough one instance that the ball bounced right off the pins, and those didn’t even move.

1 Like

Hi! Thanks for posting, this is a subtle feature of the sleep system.

As described in this article, we use both the position and velocity of an assembly to determine if it should be put to sleep.

In the case you posted, there is a (small) net force acting on the body, which produces an acceleration (and therefore a nonzero velocity). The larger the mass of the part, the smaller this velocity will be. Internally, we put a part to sleep if its velocity is less than some small (but nonzero) threshold. The reason we need a threshold is because, due to floating point and numerical drift, most parts that are visually stationary will not have a perfectly zero velocity. You can observe this by disabling sleep in studio (Studio Settings → Physics → Allow Sleep), and simulating a block resting on the baseplate. Over long enough time, the block will move, since each simulation step introduces a tiny bit of drift in its position. To make sure that parts go to sleep in these cases, we introduce a small threshold velocity value, and put parts to sleep if their velocity is below this value.

Back to the example you posted, the constraint force you are applying is producing an velocity that is below the threshold value, so it is being put to sleep. We cannot simply check if unanchored parts have a physics constraint attached to them and keep them awake if they do. For example, consider the case where two LinearVelocity constraints were applied to a part, with equal and opposite VectorVelocity values. In this case, the part velocity will be zero (up to floating point precision), and should go to sleep. We would erroneously keep the part awake if we kept it awake simply because it had a physics constraint attached to it.

We are working on more thorough documentation of the sleep system for the Creator Hub which will also provide additional guidance for developers, stay tuned!

2 Likes

Is there any way planned to disable or otherwise modify the sleep behavior? In this video, the ship should be smoothly rotating and moving downwards. It apparently does this too slowly for the physics system and is constantly set to be sleeping, which freezes it and results in the physics looking jittery. The only things affecting its position is constraints and gravity.

2 Likes

Yeah realistically it seems like the threshold values are just too high… If the precision of roblox’s engine is low enough that such a giant sleep threshold is needed maybe they should work on that lol, things that are clearly moving a considerable amount should never be slept like such, especially if we aren’t given an option to turn it off…

Good news! I’m currently auditing our sleep system, and I’ve already noticed some…interesting things about how the various sleep velocities are computed by the engine. This is ancient code and it looks like there’s some quite a lot of room for improvement!

Could you please send me the place file for this ship? I’d love to investigate exactly what’s happening here.

I also just published an article on our Creator Hub detailing the current sleep system. Please have a look and let me know if you have any suggestions for clarification!

6 Likes

Gonna jump in here to say the docs look awesome! I remember coming across this issue a while ago and was so confused (I didn’t even know sleeping parts were a thing), so I’m sure this’ll come in handy for many devs in the future. Cheers :slightly_smiling_face:

Looking forward to the improvements to the sleeping system and hope you can keep us updated here. Presuming you love revamping ancient code as much as I do, I’m sure it’ll be heaps of fun :sweat_smile:

2 Likes

The new article is very good, but what does purple outline mean as shown in the video i posted?

1 Like

I’ll look at the repro you provided, I’m not sure why it’s purple

2 Likes

Will there be a part property in the future to disable sleep? Even with the alarm clock module and unanchoring pins after a player throws, we have consistent issues with bowling balls bouncing right off of pins in our bowling game.

It’s unlikely that we’ll explicitly add the option to entirely disable sleep. Can you please create a bug report for the bowling pin issue and tag me on it? Contacts should wake the parts involved, so I’m surprised this is happening.

Thanks!

1 Like