Working hit detection code.