The content of this post has been removed.
The content of this post has been removed.
Last edited by blacknight962; 09-14-2014 at 09:03 PM.
5.17278 - 2.03122 = 3.14156 ... or as it prefers to be called Pi
So you are calculating the opposite angle, the math is the wrong way around, try:
Code:atan2(targetY - currentY, targetX - currentX);
The content of this post has been removed.
Last edited by blacknight962; 09-14-2014 at 09:01 PM.
2*PI + -1.11038 = 5.1728, so yes, it's the same. However if you're trying to rotate by a certain amount rotating by -1.1104 would be much faster than my 5.1728 (if you rotating using keyboard or whatever your problem is, if it is limited to a certain amount of degree or radian per second; interestingly, wow rotates by PI radian per second).
If you must have a positive value, learn a bit of trigonometry (Wikipedia: Unit Circle) and you'll quickly understand why you just need to add 2*PI (one full rotation). If you want to go through a rotation (like I do using the keyboard), subtract 2*PI if (while) angle > PI.
ie
//This will make sure you never go more than 180 rotating with the keyboard, even if somehow you added more than one full rotation
while rotation > PI: rotation -= 2*PI
while rotation < PI*-1: rotation +=2*PI
or
if rotation > PI: rotation -= 2*PI
if rotation < PI*-1: rotation += 2*PI
or in your case
if rotation < 0: rotation += 2*PI