Drag and Shoot in unity2d with moving camera

I have been facing an issue in using a Drag and Shoot launcher. I am taking the mouse position as input and converting it to world coordinates. Those world coordinates are also being used to draw a line renderer “lr” as Drag line to show aim direction and power. The problem I have is when the camera is moving. When the camera is moving, the startpoint goes out of view and dragpoint keeps on changing with camera even if the mouse position is still. I want the startpoint and dragpoint to not get affected by the camera movement and should only be the coordinates at which we have the mouse clicked and holded.

I tried
startPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition) - Camera.main.transform.position;

This solves the problem but the line renderer stops showing the line of drag.

if (Input.GetMouseButtonDown(0))
        {
            startPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            lr.positionCount = 1;
            lr.SetPosition(0, startPoint);

            Debug.Log(startPoint);
        }

        if (Input.GetMouseButton(0))
        {
            dragPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            lr.positionCount = 2;
            lr.SetPosition(1, dragPoint);
           
            Debug.Log(dragPoint);
        }

        if (Input.GetMouseButtonUp(0))
        {
            lr.positionCount = 0;
            endPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            //endPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition) - Camera.main.transform.position;

            force = new Vector2(Mathf.Clamp(startPoint.x - endPoint.x, minPower.x, maxPower.x), Mathf.Clamp(startPoint.y - endPoint.y, minPower.y, maxPower.y));
            rb.AddForce(force * power, ForceMode2D.Impulse);
            //SoundManager.instance.PlaySfx(release);
            groundCheck = false;
            groundCheck2 = false;
        }

https://vimeo.com/757847608

If you don’t want camera motion to figure into your finger drag vector, then don’t incorporate it.

Do all your computations in finger (screen) space, ignoring anything the camera is doing. This might include also overlaying the streak in screen space, either by moving it in world coordinates, or by doing it in some other UI layer / mechanism.

I am able to calculate the math in Screen Space and it works fine but I am unable to get the Line Renderer working with pixel coordinates. It seems to only work with world coordinates. I also tried to uncheck the “Use World Coordinates” settings in Line Renderer component but it didn’t help. I need help with getting line renderer without using world coordinates or local coordinates.

As you mentioned, something like on the UI layer or any other way.

Even if we use world coordinates for line renderer, I thought of adding the camera movement to the LR vertexes but am unable to achieve this too.