Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to stop animator state machine

Discussion in 'Animation' started by MaximumTre, Jan 3, 2021.

  1. MaximumTre

    MaximumTre

    Joined:
    Nov 28, 2015
    Posts:
    163
    Hello and Happy New Year! Let's hope 2021 is better than 2020.

    I'm using a StateMachineBehaviour on some attack animations to trigger things like hitboxes and effects. However, in the event that I want to interrupt theses to play another animation, such as a damage animation, I want the current behavior to stop. I thought that's what Animator.StopPlayback() was for, but I was wrong. I also thought by playing another animation, that should prevent the current animation from completing/reaching the normalized time I use to trigger effects, etc., but I was wrong. The animations are even on seperate layers, but still the interrupted animation keeps going. How can I make sure the animation I want to interrupt has actually been stopped?

    Things I've tried:
    Checking if the AnimatorStateInfo.fullPathHash has changed
    Checking if the layerIndex has changed
     
    Last edited: Jan 3, 2021
  2. MaximumTre

    MaximumTre

    Joined:
    Nov 28, 2015
    Posts:
    163
    OK So I guess there is no way to do this?
     
  3. MaximumTre

    MaximumTre

    Joined:
    Nov 28, 2015
    Posts:
    163
    Is there not a single person who uses the StateMachineBehaviour that can answer this?
     
  4. M-Elwy

    M-Elwy

    Joined:
    Jan 28, 2021
    Posts:
    38
    Hello, I'm not sure I understand what you mean, do you have transition from "Attack" or "Any state" to "damage" state with 0 exit time?
    I use similar approach, but i use animation events instead.