# Unity3D) Is there a way not to draw line renderer if vertex pos is zero?

I make a curved line with line renderer. and a sphere move along it. i want to draw a line only behind the sphere.

so i do something like this.

 lr.positionCount = 256;

    while (delta < time)
{
lr.SetPosition(i++, curPos);

yield return new WaitForFixedUpdate();
}




and the problem is, because of i set the size of Positions 256, if time is short, there are zero vectors in position. so line renderer draw meaningless line.

is there a way to set PositionCount dynamically like List? or any good way to not draw if positions are zero?

• you can reset positionCount in loop. something like lr.positionCount = i++; and it works like List but i don't know how it works inside... – Hree Nov 25 '19 at 12:45
• Possible duplicate of Enable / Disable LineRenderer Points. You could also clip the line in the shader, similar to this Q&A, setting the cut-off point as a material uniform so it moves as your script dictates. – DMGregory Nov 25 '19 at 14:00