Line renderer length

The question is simple: I am using a line renderer which can be moved around the player with a virtual joystick and can’t go through objects (an ability indicator) but how can I set a max length to it? I know usually a scale will solve it but it’s a child element set to world space so it doesn’t work…

        if(Physics.Raycast(transform.position, transform.forward, out hit)) {
            LR.SetPosition(1, hit.point);
        }

Use of the 4th parameter defines max distance