Check out example codes for "linerenderer follow camera unity". It will help you in understanding the concepts better.

Code Example 1

You can render the line using a dedicated camera. Use .depth to control the order in which cameras render (i.e. render the line on top of -everything-), and .cullingMask to define what each camera renders (or not).

Code Example 2

You simply have to update the points in Update to new world positions each update (and not just when you create the curve).

Something along:

int i = 0;

foreach screenPosition of my curve
   Vector3 worldPosition = camera.ScreenToWorldPoint(screenPosition); 
   lineRenderer.SetPosition(i, worldPosition);

The tricky part will be to update if you interpolate screenpositions (or worldPositions), or sample them. In either case, the slow but easy method will be to re-interpolate and resample each Update.

Once you have got this going, you can optimise by storing the the right number of points in screen space. Then you only have to convert to world space - no need to resample or reinterpolate.

Learn ReactJs, React Native from