Exemple #1
0
 private void TurnToHeading()
 {
     if ((transform.eulerAngles.y < compass.GetHeading() - 0.5f) || (transform.eulerAngles.y > compass.GetHeading() + 0.5f))
     {
         if ((compass.GetHeading() - transform.eulerAngles.y >= 0) && (compass.GetHeading() - transform.eulerAngles.y <= 180))
         {
             transform.eulerAngles += new Vector3(0f, turnRate * Time.deltaTime, 0f);
         }
         else if ((compass.GetHeading() - transform.eulerAngles.y < 0) && (compass.GetHeading() - transform.eulerAngles.y >= -180))
         {
             transform.eulerAngles -= new Vector3(0f, turnRate * Time.deltaTime, 0f);
         }
         else if (compass.GetHeading() - transform.eulerAngles.y < -180)
         {
             transform.eulerAngles += new Vector3(0f, turnRate * Time.deltaTime, 0f);
         }
         else
         {
             transform.eulerAngles -= new Vector3(0f, turnRate * Time.deltaTime, 0f);
         }
     }
 }