private IEnumerator StartTwist(int twistAmount, float twistForce, float twistAnimDuration) { UIAnimation.RotationZ(transform as RectTransform, 0, -twistForce, twistAnimDuration).Play(); yield return(new WaitForSeconds(twistAnimDuration)); float from = -twistForce; float to = twistForce; for (int i = 0; i < twistAmount; i++) { if (i % 2 == 0) { from = -twistForce; to = twistForce; } else { from = twistForce; to = -twistForce; } UIAnimation.RotationZ(transform as RectTransform, from, to, twistAnimDuration).Play(); yield return(new WaitForSeconds(twistAnimDuration)); } UIAnimation.RotationZ(transform as RectTransform, to, 0, twistAnimDuration).Play(); twistRoutine = null; }