Search Unity

Question Animation delay when trying to do state changes (HELP)

Discussion in 'Animation' started by ExtinctVenom, Sep 10, 2023.

  1. ExtinctVenom

    ExtinctVenom

    Joined:
    Feb 2, 2022
    Posts:
    3
    Hi I have an animation that is activated with left click held down and reversed when released. This happens in the same state and it works okay besides the fact that there is a delay at the start and end of the animation that gets longer the more I wait to trigger the animation. This is the code related to the animation and also a video showing this issue.
    Code (CSharp):
    1. if (Input.GetMouseButton(0) && holdingItem)
    2.         {
    3.             playing = true;
    4.             animator.SetFloat("Multi", 1f);
    5.             animator.SetBool("IsPouring", true);
    6.            
    7.         }
    8.         else if (Input.GetMouseButtonUp(0) && animator != null && playing)
    9.         {
    10.             playing = false;
    11.             animator.SetFloat("Multi", -1f);
    12.             animator.SetBool("IsPouring", false);          
    13.         }