Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Use blend tree and state animations at the same time

Discussion in 'Animation' started by Skypiggy, Oct 20, 2017.

  1. Skypiggy

    Skypiggy

    Joined:
    Jan 11, 2016
    Posts:
    9
    Hello, I properly sound really stupid but, I've been looking everywhere for answers and I'm still very confused, I'm new to animating in unity and I used Adobe Fuse/Mixamo to create a simple player that can walk around with the normal "WASD" keys. I used a blend tree to blend all the different walking animations together depending on where the character is going:
    https://imgur.com/a/eOsRw

    I was just wondering how someone could play a state animation too. The blend Tree in the picture handles the walking animations of the character beautifully, I want to add a jump animation to it but once the game starts it plays through the Blend tree non-stop and I can't play anything else on top. Whats the workaround?

    Thanks, Nathan.
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    9,774
    Hi,

    Here are some things to check:

    1. Make sure the Jump state's Has Exit Time checkbox is ticked. This lets the state run to completion (i.e., finish playing the jump) before transitioning back.

    2. Make sure Blend Tree's Has Exit Time is unticked. This allows Mecanim to transition to Jump immediately instead of waiting for the Blend Tree's animation to finish a loop.

    3. Check the transition from Blend Tree to Jump. Let's say you've defined a trigger parameter named "jump" and set the transition to occur when "jump" is true. In your script's Update() method, check for, say, the space bar and set the trigger true:
    Code (csharp):
    1. void Update() {
    2.     if (Input.GetKeyDown(KeyCode.Space)) {
    3.         GetComponent<Animator>().SetTrigger("jump");
    4.     }
    5. }
     
  3. Skypiggy

    Skypiggy

    Joined:
    Jan 11, 2016
    Posts:
    9
    Thank you very much, it was me just being stupid! ;-)