I've created a square using linerenderer but my problem now is that the line is not smooth. see below picture. I've tried enabling anti-aliasing and setting lr.numCapVertices to no avail.

enter image description here

 private void DrawLine()
GameObject myLine = new GameObject();
myLine.transform.position = start;
lr = myLine.GetComponent<LineRenderer>();
lr.material = new Material(Shader.Find("Sprites/Default"));     
lr.positionCount = 4;
lr.startWidth = .1f;
lr.endWidth = .1f;

lr.SetPosition(0, new Vector3(1, 0, 0));
lr.SetPosition(1, new Vector3(2, 0, 0));
lr.SetPosition(2, new Vector3(2, -1, 0));
lr.SetPosition(3, new Vector3(1, -1, 0));
lr.loop = true;

Gradient gradient = new Gradient();
    new GradientColorKey[]
        new GradientColorKey(Color.red, 0.25f),
        new GradientColorKey(Color.green, 0.50f),
        new GradientColorKey(Color.blue, 0.75f),
        new GradientColorKey(Color.yellow, 1f),
        new GradientAlphaKey[] { new GradientAlphaKey(1f, 0.0f)

lr.colorGradient = gradient;



1 Answer 1


Well I don't exactly know the cause of the problem but when i try to manipulate the values of linerenderer's positions, I find that when gap between the point is less then the value of 1 (-1 or 1) then we will get this weird behaviour.

however, when I increase the gap between the points then the line became crispy smooth.

Here are the some test results.

First Result

Second Result

Third Result

Now I understand completely that it is not a solution to the problem, And I am glad to know the explaination myself from anyone who know the reason that why is this happening but for now just change the position of your linerenderers points with distance greater than 1 unit.

  • \$\begingroup\$ Thanks for explaining bro if i set the unit to 1 it is not smooth. But i'll try to get a explaination why it is not smooth when setting the unit to 1. \$\endgroup\$
    – Newboy11
    Commented Mar 20, 2019 at 7:03
  • \$\begingroup\$ My advice is to avoid using line renderer whenever possible. It's a relatively poorly implemented tool. You should also be aware it's just drawing quads and connecting them by (optionally) rounded edge vertices. Depending on your use case, you're better off having a sprite. If you need color manipulation, a custom shader. But if you're not familiar with those topics then you can push ahead with line renderer. Just don't get frustrated with yourself if it doesn't work like you intend. \$\endgroup\$
    – gjh33
    Commented Mar 20, 2019 at 13:30
  • \$\begingroup\$ @gjh33 if it needs to be dynamic (for graphs) or 3D, lineRenderer is kinda the best option. \$\endgroup\$
    – Weckar E.
    Commented Aug 13, 2020 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .