MoveTowardsPoint2D

From XPUB & Lens-Based wiki
Revision as of 13:10, 18 October 2011 by Jasper van Loenen (talk | contribs)
Just the formula for now, no code examples (yet)

direction = atan2(targetY-objectY, targetX - objectX)*180/PI;

objectx += cos(direction*PI/180)*movingSpeed;

objecty += sin(direction*PI/180)*movingSpeed;