We have some behavior improvements to the physics engine ready to test now in Studio!
What’s a sleeping part?
The Roblox physics engine, like many others, uses a “sleep” system for simulated objects. Basically, when a part comes to rest, we mark it as “sleeping” and stop performing physics calculations, which freezes it in place as if it was anchored. Then, one of many different events can cause that part to “awake”, and begin performing physics calculations again.
All of this happens in the background so you ideally don’t need to worry about it. Most games have parts properly going to sleep and waking up all the time.
Unfortunately, it hasn’t been perfect. Various edge cases have been reported where parts freeze in place because they fell asleep too early, or just won’t wake up.
The cylinder falls asleep after being motionless for a bit, rather than rolling down the slope.
The large block stops moving since the small block is asleep, rather than pulling it along.
What’s changing?
We’ve totally changed how we determine when parts should go to sleep and wake up, allowing for the above broken example to work with total success. These changes should fix tons of the past reported bugs related to sleep, and we’ve been working hard to make sure existing physics mechanisms continue to work as expected.
The cylinder correctly rolls down the slope
The small block wakes up and begins moving once pulled.
Other than these broad behavior improvements, some specific fixes include:
- Switching from zero-gravity to non-zero gravity will now wake up all sleeping parts
- Parts connected to animated assemblies (Motor6Ds) will properly wake up when under motion
- Fix cases where parts would wake up when they didn’t need to.
Why beta?
Any change to a core physics system like this has the potential to create all sorts of unintended, unexpected issues. While we’ve tested lots of cases, we would hate to turn this on and see a bunch of games break. This beta allows you to test out your existing games, and make sure you don’t start seeing unexpected behavior.
Why didn’t you just give us an API to handle sleep edge cases?
This isn’t off the table. We just wanted to make these improvements since we knew the baseline could be a lot better. If we had provided an API before, there would have been little motivation to make these improvements in the first place!
Of course, if we do receive a sufficient number of cases that do not seem reasonable to have fixed with a general change, an API will be provided. The specifics of it depend on the edge cases we need to handle. So please feel free to share cases related to sleep that still appear to be broken!
Please enable this beta feature now and test your games! As long as everything goes smoothly, we will enable it everywhere after a week.