Version: Unity 6.2 (6000.2)
Language : English
Use the layer collision matrix to reduce overlaps
Collider types and performance

Select a broad phase pruning algorithm

Select the most efficient broad phase pruning algorithm.

In the Unity Editor, you can select these algorithms for broad phase collisionA collision occurs when the physics engine detects that the colliders of two GameObjects make contact or overlap, when at least one has a Rigidbody component and is in motion. More info
See in Glossary
detection:

  • Sweep and Prune (SAP): Projects Axis-Aligned Bounding Boxes (AABBs) onto axes. While generally efficient, SAP can generate false positives in large, flat worlds with many collidersAn invisible shape that is used to handle physical collisions for an object. A collider doesn’t need to be exactly the same shape as the object’s mesh - a rough approximation is often more efficient and indistinguishable in gameplay. More info
    See in Glossary
    . In these scenarios, it can identify pairs of objects for narrow phase collision checking that aren’t actually close and projections can overlap even if the objects are distant.
  • Automatic Box Pruning: Divides the world into a grid and automatically configures the boundaries and cell sizes of the world based on your sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
    See in Glossary
    ’s content. This can significantly reduce the number of pairs that need narrow phase checks in suitable environments.

SAP is the default broad phase algorithm for 3D physics. If you want to select the Automatic Box Pruning algorithm, there are several associated drawbacks you must consider:

  • Overhead in highly dynamic scenes: If your scene contains many objects that are all constantly and rapidly moving across grid cell boundaries, the overhead of updating their positions within the grid might negate or even outweigh the pruning benefits. In highly dynamic scenarios, the Sweep and Prune broad phase might be more efficient.
  • Automatic grid configuration: The automatically determined grid might not be optimal for every conceivable scene layout. While it aims for a good general-purpose configuration, specific or unusual world structures might not have as high performance benefits.
  • Initial setup and reconfiguration: There’s an initial performance cost to build the grid. If your world’s physical bounds change drastically at runtime, the system might need to reconfigure the grid, potentially causing a temporary performance spike.
  • Memory usage: The grid structure consumes some memory, though typically not a major concern.

Automatic Box Pruning generally performs well in large, open worlds, or scenes with many static or infrequently moving colliders. For smaller, dense scenes or scenes with extreme numbers of rapidly moving objects, Sweep and Prune might be a better choice. Always profile your specific scenes using the Unity Profiler, and focus on physics broad phase processing time, to determine which broad phase type yields the best performance for your game.

To change the broad phase type:

  1. Select Edit > Project Settings to open the Project Settings window.
  2. Select the Physics > Settings tab.
  3. Select the GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
    See in Glossary
    tab.
  4. In Broad phase Type, select a broad phase type algorithm.

Additional resources

Use the layer collision matrix to reduce overlaps
Collider types and performance