"Snapping to" problem with raycast. Laser sights FPS

I’m having an issue with a line renderer (which will be later changed to an actual laser particle effect) where it snaps to the hit point unnaturally. I rather not have it snap at all since the goal is just to make it not go through objects and have the sphere show up at the very end of the line. Is there a fix to achieve this?

void Update () {
        RaycastHit hit;
        if (Physics.Raycast(transform.position, transform.forward, out hit)){
            if (hit.collider){
                lr.SetPosition(1, hit.point); //lr = lineRenderer
                laserPoint.position = hit.point; //laserPoint is the sphere at the end of the laser
            }
        }
        else{
                   lr.SetPosition(1, transform.forward*5000);
                   laserPoint.position = transform.forward*5000;       
        }
}
}

This might benefit from better explanation. Do you want the laser dot to slowly move towards the new point?

The laser dot should always align with the laser. Right now the laser is snapping whenever it finds a hit target. I would much rather have it just shorten its length whenever it hits something so it doesnt look like its going through it.

I don’t know what you mean by this “snapping” behavior. The way the code is written, it looks like the laser end point should be updating every frame either with the raycast hit point on a target, or just extending out 5k distance if the raycast gets no hit.

I don’t believe Physics.Raycast ever returns true while hit.collider would be null, so I don’t think that “if” statement would ever resolve as false. But if that were possible, you wouldn’t update the position of the laser on those frames.