I have a LineRenderer path to show the path of the GolfBall. Please see in the image, maroon colour path.
private void createTrail()
{
lineRenderer.SetColors(tracerColor, tracerColor);
lineRenderer.SetVertexCount(maxVertexCount);
for (int idx = 0; idx < (maxVertexCount - 2); idx++)
{//Add another vertex to show ball's roll
lineRenderer.SetPosition(idx, new Vector3((float)pts[idx * (int)positionSampling].z, (float)pts[idx * (int)positionSampling].y, (float)pts[idx * (int)positionSampling].x));
}
lineRenderer.SetPosition(maxVertexCount - 2, new Vector3((float)pts[goal - 1].z, (float)pts[goal - 1].y, (float)pts[goal - 1].x));
lineRenderer.SetPosition(maxVertexCount - 1, transform.position);
}
The path is drawn using the points in pts[] array
.
In repeating the display, I need to clear the old path to redraw the same path again. How can I clear the old path?