Revised Angle Calculation In Unity

                Never    
C#
       
// Save these values for easy checking of sign later
float deltaX = Target.x - transform.position.x;
float deltaY = Target.y - transform.position.y;

// Calculate the angle: will be between -90-90 deg
float rad = Mathf.Atan(deltaY / deltaX);

// Figure out which quadrant we're in
// Initial angle is 0-90, so we can be in Quadrant I or III
if(rad > 0)
{
	Debug.Log("Angle is greater than 0, so should be between 0 and 90.");

	// Going down and to the left, so convert to Quadrant III
	if(deltaX < 0)
	{
		Debug.Log("Moving to the left with deltaX = " + deltaX + ", so convert to Quadrant III");
		rad = Mathf.Pi + rad;
	}
	else
	{
		Debug.Log("In Quadrant I, so keeping angle of " + rad);
	}
}
// Initial angle is -90-0, so either in Quadrant II or Quadrant IV
else if(rad < 0)
{
	Debug.Log("Angle is less than 0, so should be between -90 and 0.");

	// Going to the left, so convert to Quadrant II
	if(deltaX < 0)
	{
		Debug.Log("Moving to the left with deltaX = " + deltaX + ", so convert to Quadrant II");
		rad = Mathf.Pi - rad;
	}
	// Going to the right, so convert to Quadrant IV with a positive angle value
	else if(deltaX > 0)
	{
		Debug.Log("Going to the right, so in Quadrant IV. Converting from " + rad + " to " + ((Mathf.Pi * 2) - rad));
		rad = (Mathf.Pi * 2) - rad;
	}
}
// Angle is 0, so need to check if actually 0 or 180 deg
else
{
	if(deltaX < 0)
	{
		rad = Math.Pi * 2;
	}
}

Raw Text