I'ts better to use Raycast, because it you use the collider of the rigidbody, it may be too late then collision is detected. Raycasts are longer and you can make them detect specific layers.