title: Draw a closed circle with LineRenderer
body: <pre><code>using UnityEngine;
  using System.Collections;
  using System.Collections.Generic;
  using System.Linq;
  using System;
  
  [RequireComponent(typeof(LineRenderer))]
  public class DrawCircle : MonoBehaviour
  {
      [Range(0, 50)]
      public int segments = 50;
  
      public bool circle = true;
      [Range(0, 50)]
      public float xradius = 15;
      [Range(0, 50)]
      public float yradius = 15;
      LineRenderer line;
  
      public float drawSpeed = 0.3f;
  
      void Start()
      {
          line = gameObject.GetComponent&lt;LineRenderer&gt;();
  
          line.positionCount = (segments + 1);
          line.useWorldSpace = false;
  
          StartCoroutine(CreatePoints());
      }
  
      IEnumerator CreatePoints()
      {
          if (circle == true)
              yradius = xradius;
  
          float x;
          float z;
  
          float change = 2 * (float)Math.PI / segments;
          float angle = change;
  
          x = Mathf.Sin(angle) * xradius;
          line.SetPosition(0, new Vector3(x, 0.5f, 0));
  
          for (int i = 1; i &lt; (segments); i++)
          {
              x = Mathf.Sin(angle) * xradius;
              z = Mathf.Cos(angle) * yradius;
  
              yield return new WaitForSeconds(drawSpeed);
              line.SetPosition((int)i, new Vector3(x, 0.5f, z));
  
              angle += change;
          }
      }
  }
  </code></pre>
  
  <p>When running the game I want it will start with one line at index 0 drawn already from the center of the circle. So I added this two lines before the loop:</p>
  
  <pre><code>x = Mathf.Sin(angle) * xradius;
  line.SetPosition(0, new Vector3(x, 0.5f, 0));
  </code></pre>
  
  <p>Before adding this two lines the for loop was:</p>
  
  <pre><code>for (int i = 0; i &lt; (segments + 1); i++)
  </code></pre>
  
  <p>But now I want to start the loop from index 1 so I tried:</p>
  
  <pre><code>for (int i = 1; i &lt; (segments); i++)
  </code></pre>
  
  <p>But it's not making a complete round:</p>
  
  <p><a href="https://i.stack.imgur.com/G1tjs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G1tjs.jpg" alt="Circle"></a></p>
  
  <p>The circle drawing is moving in the clockwise direction.</p>