MoveTowardsPoint2D

From Media Design: Networked & Lens-Based wiki
Jump to navigation Jump to search
Just the formula for now, no code examples (yet)

x1, y1 = position of object to move
x2, y2 = position to move to


direction = atan2(y2-y1, x2 - x1)*180/PI;

x1 += cos(direction*PI/180)*movingSpeed;
y1 += sin(direction*PI/180)*movingSpeed;