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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Question Prevent Takehit animation connected from Any State interrupt an Rolling animation.

Discussion in 'Animation' started by hvtanh07, Apr 16, 2022.

  1. hvtanh07


    Nov 14, 2020
    I have Any State connected to Take hit animation, however, when playing Roll animation I don't want rolling animation to be interrupted, but every time player take hit, the rolling will stop immediately and play Take hit animation. Is there any way to make an exception for some animation not to be interrupted by animation connected from Any State? Screenshot 2022-04-16 131107.png
  2. Flylake


    Feb 26, 2014
    As the name implies, the "Any" state functions as essentially any state in your animation tree

    The only way to prevent an unwanted transition is to add conditions to the transition itself like you would any other.

    Add a new boolean value under Parameters, call it "Rolling" or something along those lines.

    Click the transition arrow between "Any State" and "Take Hit" and add the condition "Rolling Fase".

    Then get settled in because now you have to manage setting and unsetting that boolean flag from a script.

    An alternative is to not have the transition from Any State => Take Hit at all, and instead from your script (whichever manages the character) to call the animation directly through the Animator

    Animator myAnimator <== This would have to be a variable on the script itself, and assigned through the inspector
    myAnimator.Play("Base Layer.Take Hit", 0);