Hyluss

[Unity] Rotating over time

Jun 16th, 2020
1,393
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1.    IEnumerator RotateAxisY()
  2.     {
  3.         while (true)
  4.         {
  5.             var currentRotation = transform.localRotation;
  6.             var newRotation = currentRotation * Quaternion.AngleAxis(rotationSpeed,Vector3.down);
  7.             for (float t = 0; t < 0.5f; t += Time.deltaTime)
  8.             {
  9.                 Quaternion rotation = Quaternion.Slerp(currentRotation, newRotation,t * 2);
  10.                 transform.localRotation = rotation;
  11.                // yield return null;
  12.             }
  13.  
  14.             transform.localRotation = newRotation;
  15.             yield return null;
  16.         }
  17.     }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment