Answers for "linerenderer follow camera unity"


linerenderer follow camera unity

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

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

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