The sleep system is responsible for determining which assemblies should be simulated during each physics simulation step. If an assembly is moving very slowly and has no net forces acting on it, it is put to sleep and removed from the simulation, thereby improving performance. When a large enough force is applied to the assembly, it is woken up and simulated. All of this is handled automatically by the engine, requiring no effort from developers to achieve optimal performance.
Creating a system that handles this automatically is a considerable challenge, and a variety of issues have been identified with the help of our awesome developer community:
- Part falls asleep despite active HingeConstraint actuator
- Contraptions using PrismaticConstraint have their physics parts fall asleep at random
- PrismaticConstraint fails to move part fully sometimes
- Sleeping Parts system is completely broken, refusing to keep parts with slow-moving constraints awake
Many of these issues are a result of inconsistencies with how we determine if an assembly is moving or about to move. As a result, we’ve reworked the sleep system to both resolve these inconsistencies and deliver improved performance.
What is the change and who will it impact?
A few changes to the sleep system were made to resolve these issues:
- A more accurate check on the change in orientation to check if an assembly is rotating. This should prevent rotating objects from going to sleep prematurely and allow objects that are rotating very slowly to correctly fall asleep.
- Improved treatment of sleep-checking assemblies (sleeping assemblies that share a constraint with an awake assembly). By integrating the sleeping constraint forces, sleep-checking assemblies now fall asleep and wake when they should.
The images below illustrate these improvements on a long bridge of parts connected with hinge constraints. The existing sleep system, shown on the left, fails to put the bridge fully to sleep. When the improved sleep system is enabled, the bridge quickly falls asleep after the initial transient motion.
Legend
No Outline = Asleep
Red Outline = Awake
Orange Outline = Sleep-Checking
Purple Outline = Not yet simulating
![]() Old Sleep System Logic
|
![]() New Sleep System Logic
|
With the existing sleep system, shown on the left, mechanisms with large constraint forces sometimes jitter as individual assemblies rapidly fall asleep and wake back up. With the new sleep system logic, these mechanisms smoothly and fully fall asleep, as shown in the right-hand image.
![]() Old Sleep System Logic
|
![]() New Sleep System Logic
|
A complex locomotive fails to fall asleep with the old sleep system. When the improved sleep system is enabled, all 44 assemblies fall asleep within a few seconds.
![]() Old Sleep System Logic
|
![]() New Sleep System Logic
|
While this change potentially affects any simulated mechanism with low velocity assemblies, we believe that the vast majority of mechanisms will continue to operate as they do today.
Why should you care?
These changes fix a number of issues with the sleep system but there is the potential that they could break things for your players. To avoid any impact, you should verify that any mechanism in your experience works as intended with the improvements enabled. If not, it will need to be updated before the rollout ends.
Phased rollout details:
During the rollout, you will be able to control if the improved sleep system is enabled in your experience through the new Workspace property PhysicsImprovedSleep
with the options: Default, Enabled, and Disabled.
This phased rollout is intended to help you test whether these changes affect any of your existing mechanisms. You can do so by setting the PhysicsImprovedSleep
property to Enabled during the first phase and then testing your mechanisms.
This phased rollout will also provide a buffer to creators who may miss this announcement and experience breaking changes once we go to the second phase and Default then maps to Enabled — switching the PhysicsImprovedSleep
property to Disabled during the second phase will provide a buffer for fixing any broken mechanisms prior to us applying these changes unconditionally.
Identifying and addressing issues:
The sleep system uses a number of thresholds to determine if an assembly is moving or accelerating. Anything moving and accelerating below these thresholds will be put to sleep. The thresholds are summarized in the table below.
Threshold | State Change | Value |
---|---|---|
Linear Velocity | Awake ↔ Sleeping | 0.33 studs/s |
Rotational Velocity | Awake ↔ Sleeping | 0.42 studs/s |
Linear Acceleration | Awake ↔ Sleeping | 0.24 studs/s2 |
Rotational Acceleration | Awake ↔ Sleeping | 0.24 studs/s2 |
Neighbor Linear Velocity | Sleep-checking ↔ Awake | 0.48 studs/s |
Neighbor Rotational Velocity | Sleep-checking ↔ Awake | 0.48 studs/s |
Wake Linear Acceleration | Sleep-checking ↔ Awake | 16.9 studs/s2 |
Wake Rotational Acceleration | Sleep-checking ↔ Awake | 16.9 studs/s2 |
- The rotational thresholds reflect the velocity and acceleration of a point located on the assembly bounding sphere (a sphere that contains all of the parts in an assembly) that moves rigidly with the assembly. This ensures that a very large assembly that is rotating slowly won’t go to sleep when points far from the center of rotation are moving rapidly. The image below shows parts of three different sizes rotating at three different angular velocities. Increasing the size or angular velocity of a part prevents it from sleeping.
- If an awake assembly is moving above the Neighbor Velocity thresholds, it will wake any sleep-checking assemblies connected to it via constraints.
- A sleep-checking assembly will accelerate if the net body and constraint forces are no longer in equilibrium. If the computed acceleration of a sleep-checking assembly is above the Wake Acceleration threshold, it will wake.
The improvements to the sleep system may slightly change how your mechanisms fall asleep and wake. Depending on the type of constraints that are used in your mechanism, there are number of constraint properties you can change to ensure your assemblies don’t fall asleep prematurely:
- For Mover Constraints, try increasing
- Responsiveness
- MaxForce/MaxTorque
- MaxVelocity/MaxAngularVelocity
- For Mechanical Constraints with ActuatorType set to Motor, try increasing
- MotorMaxForce/MotorMaxTorque
- AngularVelocity
- MotorMaxAcceleration
- For Mechanical Constraints with ActuatorType set to Servo, try increasing
- LinearResponsiveness/AngularResponsiveness
- ServoMaxForce/ServoMaxTorque
- Speed/AngularSpeed
Alternatively, you can reduce the density of your parts so that any constraint forces acting on them result in faster motion.
We anticipate that most mechanisms will continue functioning correctly without any modifications. To help you diagnose any unexpected behavior, you can visualize which parts are awake and asleep.
Please report any issues you encounter in this thread, including cases where mechanisms fail to sleep when expected or fall asleep when they shouldn’t. Your feedback is crucial for us to continue refining this powerful system.
As always, please let us know if you have any questions or concerns!
Best,
Roblox Physics Team