Course contentsShow
← Unity Game Development
Lesson 213 of 8283. Physics and InteractionFree lesson

Managing Rigidbody Sleep Thresholds for Efficiency

Learners will tune sleep thresholds to ensure inactive physics objects stop calculating forces, significantly reducing the active simulation load.

In this lesson, you will learn how to use Rigidbody sleep thresholds to stop unnecessary physics calculations for stationary objects, significantly boosting your game's performance.

Understanding "Sleep" in Physics

When you have many objects in a scene—like crates, debris, or scattered props—Unity’s physics engine constantly calculates forces, collisions, and gravity for every single one, even if they aren't moving. This is a massive drain on your CPU. To fix this, Unity implements a "Sleep" state. When a Rigidbody’s movement drops below a certain energy level for a short time, it goes to sleep, meaning the physics engine stops simulating it entirely until another object bumps into it.

Tuning the Sleep Threshold

By default, Unity handles this automatically. However, you can fine-tune this behavior via the Rigidbody component in the Inspector under the Sleep Threshold property.

The threshold represents the minimum amount of kinetic energy an object must have to stay "awake." If you have heavy objects that seem to jitter or slide endlessly instead of settling, or conversely, if objects are falling asleep while still slightly rolling, you can adjust this value.

You can also set this via script if you need dynamic control:

void Start()
{
    Rigidbody rb = GetComponent<Rigidbody>();
    // Lowering the threshold makes the object stay awake longer
    // Increasing it makes it go to sleep more aggressively
    rb.sleepThreshold = 0.05f; 
}

Why This Matters

If you have a hundred physics-enabled objects, manually tuning their sleep thresholds prevents the "Physics" portion of your Profiler from spiking. An object that is "asleep" costs almost zero CPU cycles. If you notice your framerate dropping in scenes with many physical props, checking which objects are failing to enter the sleep state is your first line of defense. By ensuring objects settle quickly, you keep your physics simulation lightweight and responsive for the objects that actually matter—like your player character and active interactables.

Key Takeaway: Tuning the sleep threshold allows the physics engine to ignore stationary objects, freeing up CPU resources for the active gameplay elements that truly need them.