Collision Detection defines which algorithm the physics body (Rigidbody or ArticulationBody) uses to detect collisions. Different algorithms offer different levels of accuracy, but more accurate algorithms require more computational resources.
There are three algorithms available, represented by four collision detection modes:
Collision detection mode | Algorithm | Useful for | Not useful for |
---|---|---|---|
Discrete | Discrete | - Slow-moving collisions. | - Fast-moving collisions. |
Continuous Speculative | Speculative CCD | - Fast-moving collisions. | - Some fast-moving collisions that require an especially high degree of accuracy. |
Continuous | Sweep CCD | - Fast-moving linear collisions that require a high degree of accuracy. - Physics bodies that only collide with static colliders. |
- Collisions that happen as a result of the physics body rotating. - Physics bodies that collide with moving colliders. |
Continuous Dynamic | Sweep CCD | - Fast-moving linear collisions that require a high degree of accuracy. - Physics bodies that collide with moving colliders. |
- Collisions that happen as a result of the physics body rotating. |
For more information on each, see Overview of collision detection modes.
The following decision flow might provide a starting point for selecting a collision detection type. It starts with the least computationally intensive mode, and progresses to the most computationally intensive mode.
In some cases, you might find that the physics performance relies on a combination of the collision detection mode and the physics timestep frequency. Experiment with both and profile the results to find the right solution for your project.
To select an algorithm, set the physics body’s Collision Detection property in one of the following ways: