title: unity 2D look at upside down
body: <p>I have a patrolling 2D object that I want to look at the target it's moving towards. The problem is sometimes the object turns upside down, when the Z rotation has a high number.</p>
  
  <pre><code>Vector3 dir = target.position - transform.position;
    float angle = Mathf.Atan2(dir.y,dir.x) * Mathf.Rad2Deg;
  
    transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
  </code></pre>