Answers for "how to use line renderer moving camera unity"

C++
0

how to use line renderer moving camera unity

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);
   i++;

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.
Posted by: Guest on November-04-2020

Browse Popular Code Answers by Language