This is another common snippet used by game developers for finding the angle between two points on a plane. This function has four parameters, the first pair is the x and y values of your first point and the second pair the x and y values of your second point. It's important to note this function returns the angle in radians NOT degrees.
- function getAngle (x1:Number, y1:Number, x2:Number, y2:Number):Number
- var dx:Number = x2 - x1;
- var dy:Number = y2 - y1;
- return Math.atan2(dy,dx);
You need to login to post a comment.