SHARE
TWEET

Untitled

a guest Oct 22nd, 2017 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private IEnumerator ScanRotateRange(float range)
  2.     {
  3.         var rotationSpeed = 100f;
  4.         var initialRotation = transform.rotation;
  5.         var rightRotation = transform.rotation*Quaternion.AngleAxis(range/2, Vector3.up);
  6.         var leftRotation = transform.rotation*Quaternion.AngleAxis(-range/2, Vector3.up);
  7.  
  8.         while (transform.rotation != rightRotation)
  9.         {
  10.             transform.rotation = Quaternion.RotateTowards(transform.rotation, rightRotation,
  11.                 rotationSpeed * Time.deltaTime);
  12.             yield return null;
  13.         }
  14.         while (transform.rotation != leftRotation)
  15.         {
  16.             transform.rotation = Quaternion.RotateTowards(transform.rotation, leftRotation,
  17.                 rotationSpeed * Time.deltaTime);
  18.             yield return null;
  19.         }
  20.         while (transform.rotation != initialRotation)
  21.         {
  22.             transform.rotation = Quaternion.RotateTowards(transform.rotation, initialRotation,
  23.                 rotationSpeed * Time.deltaTime);
  24.             yield return null;
  25.         }
  26.     }
RAW Paste Data
Top