Issues with Continuous Dynamic collision.

I'm rolling a fast moving ball that has a spherical collider set to Continous Dynamic collision detection for most precise collision detection. The objects it's colliding with are capsule colliders set to Continous detection.

Now, this is the recommended configuration for detecting collision for fast moving objects in Unity. However, I'm 'occasionally' seeing the ball still sneak through the colliders at indeterminate times.

From my understanding of Continous Dynamic collision, this shouldn't be possible (unless you screw up such as scaling the parent of the rigid body or directly set translation on the rigidbody while it's moving - neither of which I'm doing.)

So I expect this to be working. Any ideas how or why Continous Dynamic could still occasionally skip collisions? I don't want to have to resort to using ray casting to ensure collision if I don't have to.

I've already searched the forum and haven't seen mention of this exact issue, so I'm trying to figure out where I must be going wrong on this...

I’ve managed to come up with pretty rock solid movements for high speed bullets, testing against each other (well, actually, each bullet has a “bullet detector” trigger collider on it, in a different layer which only listens for the bullet collider’s layer (non triggers). Bullets don’t directly interact with one another - only via their detectors.

I made the bullet a capsule, pointing along its Z (as that’s the relative axis it always travels along in this case).

I then calculate how far the bullet moves during one physics step by multiplying the muzzle velocity by Time.fixedDeltaTime

I then set the height of the capsule to that displacement step size (but also take into account the radius of the capsule affecting height).

Thus, even at very high speeds, there will be a frame where the bullet collider overlaps the bullet detector, and the bullets will not pass through one another.

Very good performance, and works well with object pooling.

Haven’t tried it with varying bullet speed (i.e. varying collider height), but I’ve little reason to think it’d stop working, so long as the height changes are made in a FixedUpdate step.

Also, this is kind of the equivalent of a collider sweep, but I’ve found that to be highly susceptible to floating point inaccuracies -not insurmountable, but a real rathole)

Your ball passes through the capsule colliders because it's velocity is so high that the distance it moves from one frame to another will bring it from one side of the capsule to the other without ever having overlapped the collider.

By reducing the timestep, more intermediate positions are calculated, and the collision is more likely to be found. That's what you've done by adjusting your timestep.

Swept collisions (also called continuous collision detection) work by determining the path of the objects as they move between frames, to determine if fast moving object's paths have collided between frames. So it should solve your problem. However, in simple replication projects, I've noticed issues with the continuous collision detection. I've filed bug 389071 with Unity, but I haven't heard back about it.

You could try to solve this by adjusting the settings in the Physics Manager and the Fixed Timestep in the Time Manager.