I'm having trouble understanding why with this script, Vector3.Angle() sometimes will never reach 0.
This question comes from me trying to make a "turret" that rotates to face a target position. It was not quite working (the angle between the turret and target would get very close to 0 and start flipping between + and - values, and never actually 0).
So to debug it I stripped the script down, and used transform.LookAt(), trying to isolate the problem. However, even using LookAt(), the Vector3.Angle() method still -sometimes- refuses to report the angle as 0, and I'm not sure why.
//Turret does not care about any Y position differences...
Vector3 currCustom = currentTargetPosition;
currCustom.y = transform.position.y; //ignore Y differences...
Debug.Log("currCustom is: " + currCustom);
Vector3 directionVector = currCustom - transform.position;
Debug.Log("directionVector is: " + directionVector);
float angle = Vector3.Angle(transform.forward, directionVector);
Debug.Log("angle is: " + angle);
transform.LookAt (currCustom);
The attached image should also help demonstrate what is going on (note that the object doing the checking is an empty GameObject located roughly where the orange square is).
Any ideas as to what I'm doing wrong are appreciated, thank you for reading.