title: unity3d rotate back forth with limited angles
body: <p>I'm want to rotate an object on an axis for specific angles over period of time.
  And repeat that on the reverse direction once it reached the limit (of let's say 5 degree).</p>
  
  <p>I could use Quaternion.Euler() to do the rotation towards 5 degree, but how do I check whether it has reached 5 degree and start reversing the direction towards -5 degree?</p>
  
  <p>so in Update() I do:</p>
  
  <pre><code>int dir = 1; // somewhere global
  
  Quaternion r = Quaternion.Euler(0, Timer.deltaTime * dir, 0);
  
  transform.rotation *= r;
  
  // I want to: if the "angle is &gt;= 5f", i want to do dir *= -1 to reverse it 
  
  if (/* angle delta is &gt;= 5f or &lt;= -5f */)
  {
      dir *= -1;
  }
  </code></pre>
  
  <p>Thanks</p>