Search Unity

Key frame animations don't play

Discussion in 'Animation' started by Tixal, Jan 21, 2021.

  1. Tixal

    Tixal

    Joined:
    Mar 9, 2017
    Posts:
    15
    Hi, I have a problem with my key frame animations playback. I control the animations from the code with Invoke methods, the code is very simple and it's basically something like this:

    public void ButtonA_click()
    {
    AnimShake.speed = 1.0f;
    Invoke("StopAnimation", Delay);
    }

    private void StopAnimation()
    {
    AnimShake.speed = 0.0f;
    }

    The Delay length is adjusted to be the half of the animation duration. However there are times when the animation stops playing much earlier than the end of the duration. I've noticed that this is happening mostly when I change the aspect-ratio from the Unity editor. Do you have any ideas what could cause this problem, thanks :)