Course contentsShow
← Unreal Engine Game Development
Lesson 296 of 8804. Advanced Input and PhysicsFree lesson

Optimizing Destruction Performance with Sleep Thresholds

Configure sleep thresholds and mass properties to force inactive debris into a dormant state, significantly reducing CPU overhead during large-scale destruction.

In this lesson, you will learn how to use sleep thresholds to force static debris fragments into a dormant state, drastically reducing CPU load during large-scale destruction.

The Problem with Active Debris

When you trigger a major fracture using a Geometry Collection, Unreal Engine calculates the physics for every individual shard. Even if a piece of rubble has barely moved, the physics engine continues to calculate its velocity, angular momentum, and potential collisions. If you have hundreds of shards scattered across a scene, this "active" calculation eats up CPU cycles that could be better spent on game logic or rendering.

What are Sleep Thresholds?

A Sleep Threshold is a physics setting that tells the engine: "If this object’s movement is below this specific value for a certain amount of time, stop calculating its physics entirely." When an object "sleeps," it is removed from the active physics simulation loop, saving significant performance.

Configuring Sleep in Geometry Collections

You can tune these settings within your Geometry Collection asset or on the instance level:

  1. Sleep Linear Threshold: This defines the minimum speed (units per second) below which the object is considered "still."
  2. Sleep Angular Threshold: This defines the minimum rotation speed (degrees per second) for dormancy.

By increasing these values, you make your debris "go to sleep" faster. For example, setting these to a slightly higher value ensures that shards stop simulating the moment they settle on the ground rather than jittering in place for seconds.

You can also adjust the Mass properties. Heavier objects are less likely to be nudged by minor collisions, which helps them reach that sleep threshold sooner.

// Logic conceptually applied to physics bodies within the Geometry Collection
FBodyInstance* BodyInst = MyGeometryCollectionComponent->GetBodyInstance();
if (BodyInst)
{
    BodyInst->SleepLinearThreshold = 0.5f;
    BodyInst->SleepAngularThreshold = 0.5f;
}

By forcing inactive debris into a dormant state, you ensure that your scene remains performant, allowing you to maintain high-fidelity destruction without tanking your framerate.

Key Takeaway: Sleep thresholds allow the physics engine to ignore stagnant debris, freeing up essential CPU overhead by removing inactive objects from the simulation loop.