Search code examples
unity-game-enginedrawing

Is it really so difficult to draw smooth lines in Unity?


I been trying for a while to draw smooth lines in Unity but with Line Renderer I obtained only jagged lines with the corners not rounded, in particular when the angle of curvature is really small . I incresed the value of antialiasing in quality settings and tried different materials but nothing changed. I also tried to instantiate a sphere every time the mouse move but it creates some gaps between the various spheres, in particular when the mouse go fast. I know there is a plugin called Vectrosity for this but there is a way to achieve this whitout it?


Solution

  • I obtained only jagged lines with the corners not rounded, in particular when the angle of curvature is really small .

    This was a problem in Unity 5.4 and below. This problem has been fixed in Unity 5.5 and above after LineRenderer was completely re-designed.

    All you have to do is update to Unity 5.5 or version above and this problem should go away.

    There is a new variable called LineRenderer.numCornerVertices. You can use that to set how smooth you want the line to be. The value of 5 seems fine for this.

    There is also another new variable called LineRenderer.numCapVertices that can be used to set how smooth the end of the line should be.

    This is a screenshot that demonstrate between 5.4 and 5.5 the changes:

    enter image description here