Search Unity

Animation not allways stops at the end

Discussion in 'Animation' started by SmartMediaNL, Nov 11, 2016.

  1. SmartMediaNL

    SmartMediaNL

    Joined:
    Sep 29, 2016
    Posts:
    77
    On devices with a low framerate I noticed that even a single basic animation isn't always playing until the end of the animation.
    The exit time i have set to 1 with a keyframe at the end of the animation dasn't prevent the animation from stopping before the end is reached on device with a low FPS.
    I can test this in de Unity editor also by forcing the FPS to a very low value like this:

    QualitySettings.vSyncCount =0;
    Application.targetFrameRate =10;

    Doing this will make the animation stop before executing the final key frame location at different timeline locations near the end frame. Resulting in objects almost reaching the end coordinates but not reaching it completely (most of the time or some of the time depending on the FPS) and every time the end location is a bit different.

    The workaround i done so far is to add an copy of the keyframe later in the timeline and making the timeline longer. Or moving the animation to a new animation that has the end values from start to end but that seems a bit over the top.

    In some cases i noticed that also the code event i placed in the timeline wasn't triggered at times.

    Am i missing something or is this a known bug ?
     
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    yes this is a know issue.
    the animation doesn't stop. it's related to how unity tick the animation system.
    each black line represent a tick by the engine.

    tick.png

    depending how often you get ticked you may get different end result.

    Setting the animator update mode to AnimatePhysic can reduce the issue because you get fixedupdate but still there is no guarantee that it will close the animation and it cost more cpu power.
     
    MisterChilindrM likes this.
  3. SmartMediaNL

    SmartMediaNL

    Joined:
    Sep 29, 2016
    Posts:
    77
    Thanks! That explains a lot!
    I hope that someday their will be an change to this system. Like not leaving current animation until the last keyframe is done by for example setting a flag.
    As I would expect when setting the exit time to 1f and having the last keyframe at the end.
    At least I know now that it isn't some setting I wasn't aware off.