I have object that runs towards a set destination (set through right-click) and the object arrives perfectly but I also have a desired rotation being stored when the user holds down the right mouse button and picks a rotation (a graphical arrow appears to show rotation). Everything works until the object reaches its destination when I want the object to rotate to face the desired rotation. I have a check method to see if the rotation difference between the object and desired but it always returns zero, even if I manually rotate the object (just around the y-axis), no matter what it always comes back as a zero difference.
bool CheckAngleDifference(Quaternion a1, Quaternion a2,float diffAmnt)
{
print (a1 + " - " + a2);
print ("angle diff: " +Quaternion.Angle (a1, a2));
if (Mathf.Abs (Quaternion.Angle (a1, a2)) > diffAmnt)
return true;
return false;
}
I have made this work using:
Quaternion.Angle (transform.rotation, (Quaternion.LookRotation (newDest - transform.position, Vector3.up)))
but in this case the positions are the same since it has arrived at its destination. Any idea why Quaternion.Angle keeps coming back as zero and how can I get the object to face the desired rotation after arriving at its destination.
Big thanks in advance for any hep.