Search Unity

Access cycle from Blend Tree

Discussion in 'Animation' started by MetalDonut, Dec 22, 2019.

  1. MetalDonut

    MetalDonut

    Joined:
    Feb 7, 2016
    Posts:
    127
    Hey folks,

    I'm using a blend tree for my idle/walk/run animations. I'm not using root motion so am moving the character through my own controller.

    When I stop moving from walk to idle the feet can skate a little if the character is in certain parts of the walk cycle. To avoid this, I'm thinking if I can check what stage of the walk cycle I'm in when the user input is stopped - and if not desirable - I can force the animation and movement to continue a few frames.

    How can I check where in the cycle my animation is from script from a blend tree? Couldn't find a clear explanation of this online anywhere. Also, if there is a better way to ensure a natural blend to idle would love the advice!

    Thanks,

    MD
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    There isn't much information you can get about the internal workings of a Blend Tree, but animator.GetCurrentAnimationStateInfo should give you access to the blended normalized time.

    You might also be interested in the Mixer States feature of my Animancer plugin. Mixers are basically like Blend Trees, but you have full access to all their internal details. In Animancer v4.0 (currently in Beta) I've added Mixer Time Synchronisation which allows them to give notably better blending between Idle and Walk animations.
     
  3. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    you can add curves to the animation
    like this

    and you can get the curve's value, like if the variable is 1, the cycle ends
     
  4. MetalDonut

    MetalDonut

    Joined:
    Feb 7, 2016
    Posts:
    127
    Will check it out, thanks