Trying to stop telescoping at high speeds

I’m adding a telescoping check on my controller’s fixed update.

Basically I’m shooting a linecast between each frame and then repositioning the player to the hit point.

That way if the player moves fast enough to make gaps between frames the line will catch it.

The only trouble I’m having is that if I don’t also zero the velocity it just picks up where it left off and doesn’t check the collision before going to the next update.

Is there a way that I can have it collide without having to zero the velocity?

//This is called every FixedUpdate();
void CheckTelescoping(){
        Vector3 positionMark = new Vector3 (0,0,0);
        var layerMask1 = 1 << 0;
        var myLayerMask = layerMask1;
        RaycastHit hit;
        if (Physics.Linecast(positionMark, transform.position, out hit, myLayerMask)){
            transform.position = hit.point;
            myRigidbody.velocity = Vector3.zero; //This is the bit of code I want to be able to get rid of.
            Debug.Log("BONK!");
        }
        positionMark = transform.position;
    }

Question will be, what sets your velocity?
Do you have other scripts, which may affect it?
Or the velocity is, the difference between current and previous position?
Technically, you should have myRigidbody.position, rather than transform.position in your case.

If you’re using rigid bodies why not just change the rigid body mode to ‘Continuous Dynamic’ which will switch on continuous collision and stop it jumping through gaps?