Comments and answers for "Follower Airplane problem"
http://answers.unity.com/questions/182695/follower-airplane-problem.html
The latest comments and answers for the question "Follower Airplane problem"Comment by Master2112 on Master2112's answer
http://answers.unity.com/comments/183464/view.html
(just found out i can comment, i'm new :P) Thanks for the code! ill try it and tell you if i got it to work :)
Le Edit: trying to get my plane to use it, but it would help if i knew how to put the code in my plane.
Le Second Edit: Got it to work! thanks a lot :PSun, 06 Nov 2011 09:12:32 GMTMaster2112Answer by MattWhiting
http://answers.unity.com/answers/183074/view.html
I found this helper function in Unity's math library:
[MoveTowardsAngle][1]
http://unity3d.com/support/documentation/ScriptReference/Mathf.MoveTowardsAngle.html
Here's a thread on wrapping angles:
[wrapping-euler-angles-to-achieve-mouse-look][2]
To save you some time, the easy-to-understand and correct answer is this:
float WrapAngle(float ang) {
while (ang > 180.0f)
ang -= 360.0f;
while (ang <= -180.0f)
ang += 360.0f;
return ang;
}
the more mathematically efficient version is this:
float WrapAngle(float ang) {
int n = (int)(ang / 180.0f);
if (n & 1)
n += (n < 0 ? -1 : 1);
return ang - (float)(n * 180);
}Fri, 04 Nov 2011 19:32:09 GMTMattWhiting