Coroutine Animate over time



    Jason Storey

    The IEnumerator interface has three methods:

    The first method, Co_OverTime, takes two parameters: the duration of the animation and a function to be executed on each animation frame.

    The second method, onTick, takes three parameters: the duration of the animation, the animation curve to use (if provided), and a boolean flag indicating whether the animation should start automatically on frame tick or not.

    The last method, AnimationCurve, takes only one parameter: a curve to use for the animation.

    Library: Animation

    IEnumerator Co_OverTime(float duration, Action<float> onTick,AnimationCurve curve = null)
      float timer = 0;  
      curve ??= AnimationCurve.EaseInOut(0, 0, 1, 1);  
      while (timer < 1)  
      timer += Time.deltaTime / duration;  
      yield return null;  
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.