Search Unity

Question Animation time doesn't match the time passed

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

  1. eagleknight42

    eagleknight42

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

    Code (CSharp):
    1. AnimationClip[] clips = animator.runtimeAnimatorController.animationClips;
    2.             foreach(AnimationClip clip in clips)
    3.             {
    4.                 switch(clip.name)
    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?