Unity Animation Event doesn't work.



  • Animation Move. consists of one staff and one Event♪ In case this animation begins after Endthe player's jealous. Move.but method Event It's not starting to block traffic.

    введите сюда описание изображения

    Code where the obsession occurs:

    private IEnumerator PostMove()
    {
        // ждём окончания движения
        while (animator.GetBool("isMove")) { yield return new WaitForFixedUpdate(); }
        // запускаем корутину обычного движения
        mainDirection = secondDirection; 
    
    animator.SetBool("isMove", true);
    secMovement = null;
    secondDirection = Direction.zero;
    

    }

    After a change in line animator.SetBool("isMove", true); There's a change of attitude. Move.but Event It doesn't work.

    Addendum yield return new WaitForFixedUpdate(); before animator.SetBool("isMove", true); Everything works better, but sometimes things hang out.
    Used State Machine Behaviours:

    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
    animator.GetComponent<Player>().StartMove();
    }

    But there's a similar situation.

    Why doesn't Event work and how can we fix it?



  • Got it. It's a stupid mistake, but suddenly someone's gonna help. Event and similar functions Unity They didn't work because animator and did not get out of my condition despite the fact that animator.SetBool("isMove", false); because it must have returned in the same frame, following the direction of the control crypt, in my case.

    Found the experimental path with help. State Machine Behaviours



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2