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 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 detectionAn automatic process performed by Unity which determines whether a moving GameObject with a Rigidbody and collider component has come into contact with any other colliders. More info
See in Glossary 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. |
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: