That's why sensor fused weapons were developed.
https://en.wikipedia.org/wiki/CBU-97_Sensor_Fuzed_Weapon
had to look that up