title: SFML - Move object towards coord
body: <p>so I am working on an AI system with C++ and SFML in which I want the enemies to follow the player. Im going to create it so the enemies are moving towards the point at which the player was 30 frames ago (so it will constantly updating). But my question is simple, what is the math behind getting the enemy to move to a specific point? Like let's say the player is at (230, 400) and the enemy is at (100, 200) how do I get the enemy (using the .move() function with a speed of 3) to move to that point? Any help would be fantastic!</p>
  
  <p>---UPDATED BELOW WITH CURRENT CODE FOR HANDLING MOVEMENT-----</p>
  
  <pre><code>float angle = atan2(v2iEnemyPos[1].y - rsPlayer.getPosition().y, v2iEnemyPos[1].x - rsPlayer.getPosition().x);
      angle =angle * 180 / (atan(1) * 4);
     sf::Vector2f newpos((cos(angle))*2, (sin(angle))*2);
      std::cout &lt;&lt; newpos.x &lt;&lt; " " &lt;&lt; newpos.y &lt;&lt; std::endl;
      rsEnemy[1].move(newpos.x, newpos.y);
      rwWinOne.draw(rsPlayer);
      rwWinOne.display();
      rwWinOne.clear();
  </code></pre>