Search Unity

Question Animation blending for opposite inputs in blend-tree

Discussion in 'Animation' started by Grant151, Jun 10, 2020.

  1. Grant151

    Grant151

    Joined:
    Sep 12, 2013
    Posts:
    65
    Hi all! I have a blend-tree for a simple run cycle, which blends animations based on the input direction (in degrees from -180 to 180) from the WASD keys. It words fine when blending animations that are adjacent (walk forwards and walk left) but does not work properly for opposite animations (walk back and forward, or walk left and right). In case when I press D and then press A, i want the animations to blend from walk right to walk left, but right now they blend from walk right to walk forward, and only then walk left. If I make the input direction parameter to change instantly (from -90 to 90 degrees), then the blendtree transitions from left to right, but no smoothing is applied and it looks very jerky.

    Here is someone else's video with the same problem and he got no answer

    Full post: https://answers.unity.com/questions/1724027/how-can-i-transition-between-animations-with-oppos.html

    In short: how do I blend animations with opposite input directions in the blend tree?
     
  2. secondstreet

    secondstreet

    Joined:
    May 21, 2017
    Posts:
    5
    I'm just starting to learn blend trees, so I can only venture guesses. I'm assuming here that when there is an extreme change of direction, you want the character to be facing the in the new direction, as opposed something like moving sideways while facing forward, as in strafing.

    Perhaps one of the following can lead you in the right direction:
    • If you're okay with your character making a change of direction in a more rounded way, as opposed to pivoting in place, you could use an animation you already have as a transition in your blend tree between the two extreme directions (e.g moving left --> moving forward --> moving right).
    • If you don't want a rounded turn, you could create a new animation that handles how your character would move when doing a hard pivot turn and add that as a transition in your blend tree between the two extreme directions (e.g. moving left --> new 180 degree pivot animation --> moving right).
    • In your C# script that handles user input, perhaps it is possible to rotate your character in a way that looks natural (e.g. maybe time based) whenever such a instant change to the opposite direction occurs (or at least a change of direction that is greater than a certain number of degrees). This is beyond anything I've done yet, so this is truly a guess.
    Hope this helps.


    UPDATE
    You might also look at this: Unity Forum - Jerky movement in blend tree
     
    Last edited: Jun 16, 2020