private static IEnumerator RotateRoutine(RotationContainer data, Action <Quaternion> callback) { float elapsed = 0; while (elapsed < data.Duration) { data.CurrentRotation = Quaternion.Lerp(data.CurrentRotation, Quaternion.Euler(data.TargetRotation), elapsed / data.Duration); callback?.Invoke(data.CurrentRotation); elapsed += Time.deltaTime; yield return(null); } data.CurrentRotation = Quaternion.Euler(data.TargetRotation); callback?.Invoke(data.CurrentRotation); }
public static Coroutine Rotate(RotationContainer data, Action <Quaternion> callback) { CheckForObject(); return(_routinesObject.StartCoroutine(RotateRoutine(data, callback))); }