title: rotation and origins building a path. XNA
body: <p>I'm trying to build a path system involving the use of paths with waypoints. At the moment I'm trying to render the path to the screen. I'm getting some success.</p>
  
  <p>But, I have a problem being, between these checkpoints I need to make "lines". The logic is below.</p>
  
  <pre><code>    for (int i = 0; i &lt; paths.Count; i++)
          {
              for (int j = 0; j &lt; paths[i].wayPoints.Count; j++)
              {
                  if ((j + 1) &lt; paths[i].wayPoints.Count)
                  {
                      Vector2 point1 = paths[i].wayPoints[j];
                      Vector2 point2 = paths[i].wayPoints[j + 1];
                      Vector2 origin = new Vector2();
  
  
                      float angle = (float)Math.Atan2(point2.Y - point1.Y, point2.X - point1.X);
                      float length = Vector2.Distance(point1, point2);
  
                      //batch.Draw(tileTexture, new Rectangle((int)point1.X, (int)point1.Y, cellSize, cellSize), Color.White);
  
                      batch.Draw(tileTexture, new Vector2((int)point1.X, (int)point1.Y), null, Color.White,
                          angle, origin, new Vector2(length/40, 1),
                          SpriteEffects.None, 0);
                  }
             }
        }
  </code></pre>
  
  <p>The problem I'm having is that I can't get my enemies to follow this path. Dependent on the rotation, they can go on the wrong side of the path. e.g. they go one cll too far to the right when travelling towards the bottom of the screen but when going back up, they're in the right cell, where the path is drawing. I had this working with a map and drawing using rectangles if that's any help.  </p>