Animation running faster than expected

Hello,

While button is pressed, I am spawning an object in update() once a second, and I turn animation on upon spawning the projectile.

The animation cycle is set to be 1 second in the animator. So ideally, the animation should be coordinated with spawning the new projectile.

However, the animation is running faster than 1 second, and if I keep holding the button, the error accumulates and it is obvious that the two are not in sync.

In other words, although my animation is supposed to last 1 second, it is completing in around 0.9 seconds!

My logic is something like this in the update()

update()
{
   fireTimer += Time.deltaTime;
   //...
     if (fire > 0.5 && fireTimer > 1f) // fire > 0.5 implies button is pressed
        {
          fireTimer = 0;
          ac.enabled = true; // enables animation controller
         // instantiate object...
        }
    else if(fireTimer > 1f)
    {
        ac.enabled = false;
    }
}

I finally found a workaround, although didn’t know why the issue occurred.


When I generated animation, it automatically created controller for me. I added an idle state in the animator, and then a trigger form the idle state to the animation.


I enable the animation in the Start(), then I set a trigger from the Update().