title: Move and Rotate LineRenderer with Transform property
body: <p>You can rotate any visual Object in Unity with the Transform property. One exception is the <a href="https://docs.unity3d.com/ScriptReference/LineRenderer.html" rel="nofollow noreferrer"><code>LineRenderer</code></a>. You can't move or rotate it with the transform property. </p>
  
  <p><a href="https://docs.unity3d.com/ScriptReference/LineRenderer.html" rel="nofollow noreferrer"><code>LineRenderer</code></a> is moved with the <a href="https://docs.unity3d.com/ScriptReference/LineRenderer.SetPosition.html" rel="nofollow noreferrer"><code>SetPosition</code></a> or <a href="https://docs.unity3d.com/ScriptReference/LineRenderer.SetPositions.html" rel="nofollow noreferrer"><code>SetPositions</code></a> function so I <a href="https://stackoverflow.com/a/47209252/3785314">managed</a> to make it movable by the transform position property but I can't make make it rotate too.  </p>
  
  <p>Below is the code I am using to make it movable.</p>
  
  <pre><code>public Vector3 beginPos = new Vector3(-1.0f, -1.0f, 0);
  public Vector3 endPos = new Vector3(1.0f, 1.0f, 0);
  
  Vector3 beginPosOffset;
  Vector3 endPosOffset;
  
  LineRenderer diagLine;
  
  void Start()
  {
  
      diagLine = gameObject.AddComponent&lt;LineRenderer&gt;();
      diagLine.material = new Material(Shader.Find("Sprites/Default"));
      diagLine.startColor = diagLine.endColor = Color.green;
      diagLine.startWidth = diagLine.endWidth = 0.15f;
  
      diagLine.SetPosition(0, beginPos);
      diagLine.SetPosition(1, endPos);
  
      //Get offset
      beginPosOffset = transform.position - diagLine.GetPosition(0);
      endPosOffset = transform.position - diagLine.GetPosition(1);
  }
  
  void Update()
  {
      //Calculate new postion with offset
      Vector3 newBeginPos = transform.position + beginPosOffset;
      Vector3 newEndPos = transform.position + endPosOffset;
  
      //Apply new position with offset
      diagLine.SetPosition(0, newBeginPos);
      diagLine.SetPosition(1, newEndPos);
  }
  </code></pre>
  
  <p>I tried to use the-same method I used to make it able to rotate but I am stuck in the first step of getting the offset because there is no way to access the rotation variable for <code>LineRenderer</code> but there is one for accessing the  position <a href="https://docs.unity3d.com/ScriptReference/LineRenderer.GetPosition.html" rel="nofollow noreferrer"><code>GetPosition</code></a>. </p>
  
  <p><em>How can I get the <code>LineRenderer</code> rotation or how can I also make <code>LineRenderer</code> be rotated from the Transform property?</em></p>
  
  <p>Below is an image that shows the behavior of <code>LineRenderer</code> with and without the script above. Position is now working with the script above enabled but rotation is not.</p>
  
  <p><img src="https://i.imgur.com/dL56H4n.gif" width="900" height="400"></p>