# Draw smooth curve with linerenderer

Hi !

Please, I need your help. I want to draw randomly smooth curves with lines renderer but I don’t succed to do it.
I found some solutions but they don’t correspond to my expectations. They add vertices in my curve even when my line is almost straight. This is my method which add vertices below :

``````private void AddVertices()
{
if (vertices == null)
{
vertices = new List<Vector2>();
}

GameObject.Find("StartPoint").GetComponent<LevelLimit>().SetPosition(start);

for (int index = 0; index < pathSize; index++)
{
Vector2 newVertex = new Vector2();

float lastX = vertices[vertices.Count - 1].x;

newVertex.x = lastX + segmentLength;
newVertex.y = RandYPos();

}

GameObject.Find("EndPoint").GetComponent<LevelLimit>().SetPosition(end);
}
``````

Can you help me please ?

Thanks a lot for answers !

If this causing any actual problems?

Yes, because if there is only 3 vertices in my line which are almots aligned, I would like to see a line and not a curve.
However, solutions that I found add vertices and make curves at any time.

“Almost straight” is not “straight”, so it needs verts. How many is it adding?

Around 100.

Why are you applying a set amount and not just subdividing based on the length of the line?

I apply subdividing. In my function, I’m using pathsise which is the lenght of the line. I subdivided before to find segmentLength which is the distance between two vertices.
My function give to me a line and I want to make the line more curved if angles are important. However if my the vertices in my line are almost aligned and the line seems straight, I don’t want to modify it. Solutions that I found modified it in each case. In my code above, I don’t show these solutions.