Advertisement
Guest User

Untitled

a guest
May 26th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. IEnumerator rotate90(bool direction)
  2. {
  3. // direction == false -> rotate left
  4. // direction == true -> rotate right
  5.  
  6. if (direction == true)
  7. {
  8. CurrentLookVector = (LookVector)(((int)CurrentLookVector + 1) % 4);
  9. }
  10.  
  11. else
  12. {
  13. CurrentLookVector = (LookVector)(((int)CurrentLookVector - 1));
  14.  
  15. if ((int)(CurrentLookVector) == -1)
  16. {
  17. CurrentLookVector = (LookVector)(3);
  18. }
  19. }
  20.  
  21.  
  22. Quaternion startRotation = transform.rotation;
  23.  
  24. Quaternion endRotation;
  25.  
  26. if (direction == false)
  27. {
  28. endRotation = startRotation * Quaternion.Euler(0, -90, 0);
  29. }
  30.  
  31. else
  32. {
  33. endRotation = startRotation * Quaternion.Euler(0, 90, 0);
  34. }
  35.  
  36. float t = 0.0f;
  37.  
  38. float seconds = CameraRotateTime;
  39.  
  40. while (t <= 1.0f)
  41. {
  42. t += Time.deltaTime / seconds;
  43.  
  44. transform.rotation = Quaternion.Lerp(startRotation, endRotation, Mathf.SmoothStep(0.0f, 1.0f, t));
  45.  
  46. yield return new WaitForFixedUpdate();
  47. }
  48.  
  49. rotating = false;
  50. yield return null;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement