In this lesson, you will learn how to enable Continuous Collision Detection (CCD) to prevent fast-moving projectiles from passing through solid walls.
The Tunneling Problem
When you fire a bullet, Unreal Engine’s physics solver calculates its position at discrete intervals. If a projectile is moving fast enough, it might be in front of a thin wall in one frame and behind it in the next. Because the engine never technically "saw" the bullet touch the wall, the projectile simply disappears or appears on the other side. This common glitch is known as tunneling.
Solving Tunneling with CCD
Continuous Collision Detection (CCD) solves this by calculating the path of an object as a sweep volume rather than a single point. Instead of asking "Where is the projectile now?", the engine asks, "Did the projectile cross a collision boundary while moving from point A to point B?"
To enable this on your projectile actor:
- Select the Static Mesh Component or Collision Component representing your projectile.
- In the Details panel, search for "CCD."
- Check the box labeled Use CCD.
If you are spawning projectiles via C++ or blueprints, ensure the collision settings are configured for dynamic objects. You can also toggle this setting programmatically during runtime if you only need the high-accuracy checks when the projectile reaches certain speeds:
// Example: Enabling CCD on a projectile's collision component
MyProjectileCollision->SetUseCCD(true);
Performance Considerations
While CCD effectively stops tunneling, it is more computationally expensive than standard discrete collision. Because the engine performs extra math to check the "sweep" of the object, you should only enable CCD on fast-moving, small objects that need to pass through thin geometry. Avoid enabling it on large, slow-moving physics actors, as it will unnecessarily consume your physics simulation budget.
By selectively applying CCD to your high-velocity entities, you ensure that your projectiles register hits reliably, keeping your combat interactions tight and professional.
Key Takeaway: Use Continuous Collision Detection (CCD) for fast-moving objects to calculate their trajectory path and prevent them from "tunneling" through thin geometry.