Collider suddenly stops detecting collision? (bug?)

So a few months back I was working in a 2D project. It happened very frequently where 2D colliders (box etc) suddenly stop detecting collision for no reason. I have to disable/re-enable the collider or the gameObject the collider’s attached to for collision detection to get back. I thought this was a 2D bug. After some searching, I found a lot of people complaining about 2D so yeah, it’s a 2D bug… I got around it by writing a script that ‘refreshes’ the object on certain intervals (very silly)

But now I’m in 3D, and actually just came across this problem… I was recording a demo for my team and it happened a couple of times during that video. Have a look (@1:55 where I was shooting the left arm, but it didn’t react till I disabled/renabled its collider. Also its clearly visible after 3:10 - The right legs/thighs and his left arm afterwards… the raycast is just going right through them to the other side…)

If anyone have any idea It’d be really appreciated.



A little info: I’m not instantiating bullets with speed and detecting their collision with body parts, I’m just using raycasts to shoot. Notice at 3:10 the raycast isn’t even intersecting/hitting the legs - when I disable/renable the leg it immediately detects the ray… In other words I don’t really need to shoot for some parts not to detect the raycast…

I actually have two raycasts, one for debugging (why you see the red ray with the red dot at the end…), and one for shooting (does the actual detection)

	private void OnDrawGizmos()
		Vector3 tipPos = gunTip.position;
		Vector3 tipFwd = gunTip.forward;
		Vector3 end;
		RaycastHit hit;
		if (Physics.Raycast(tipPos, tipFwd, out hit, Distance, shootingMask))
			end = hit.point;
		else end = tipPos + tipFwd * Distance;
		GizHelper.DrawLine(tipPos, end,;
		GizHelper.DrawSphere(dbgLastShot, .025f,;
		GizHelper.DrawSphere(end, .025f,;

	private void Shoot()
		// Sound, muzzle and ammo decrease...

		RaycastHit hit;
		if (Physics.Raycast(gunTip.position, gunTip.forward, out hit, Distance, shootingMask))
			log("Shot: " +;
			dbgLastShot = hit.point;

			var receiver = hit.collider.GetInterface<IHitReceiver>();
			if (receiver != null)
				receiver.ReceiveHit(gunTip.position, damage);

I now suspect: static colliders.

“Worse still, the changes can sometimes leave the collider in an undefined state that produces erroneous physics calculations. For example a raycast against an altered Static Collider could fail to detect it, or detect it at a random position in space.” → from the Colliders Overview in the manual.

Try adding kinematic Rigidbodies to each object with a collider. Then when the limbs move they’re not leaving the collision system in a broken state. This may also explains why disable->enable fixes the problem.