Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question Animation time doesn't match the time passed

Discussion in 'Animation' started by eagleknight42, Apr 23, 2023.

  1. eagleknight42


    Oct 23, 2021
    Hello. I get the animation times using:

    Code (CSharp):
    1. AnimationClip[] clips = animator.runtimeAnimatorController.animationClips;
    2.             foreach(AnimationClip clip in clips)
    3.             {
    4.                 switch(
    5.                 {
    6.                     case "Equip":
    7.                         equipAnimTime = clip.length;
    8.                         break;
    9.                     case "Shoot":
    10.                         shootAnimTime = clip.length;
    11.                         break;
    12.                     case "Reload":
    13.                         reloadAnimTime = clip.length;
    14.                         break;
    15. }}
    and change my parameters in animator like this

    Code (CSharp):
    1. animator.SetBool(shoot,true);
    2. waitforseconds(shootAnimTime);
    3. animator.SetBool(shoot,false);
    But parameter "sometimes" becomes false before animation ends and animation switches state. So time is not passed exact like in animator. How can I fix this? Should I use exit time or something like that?