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

Blend Tree animation bug?

Discussion in '2D' started by Beshi38, Dec 4, 2021.

  1. Beshi38

    Beshi38

    Joined:
    Feb 7, 2021
    Posts:
    5
    Hello,

    I use the blend tree to change animation when I change direction with my character.

    On the y-axis everything works correctly, the animations change when the value of y is lower than 0 or higher than 0.

    When I move the character to the left the animation is played as it should be but when I want to go to the right it is the left animation that is played until the value of x is greater than 0.90. When x is higher than 0.90 the right animation is played.

    Capture d’écran 2021-12-04 072840.png

    Here is how I get the values of x and y (I use the new input system).

    Code (CSharp):
    1. private void InputMovementReadValue()
    2.     {
    3.         Vector2 inputVector = playerInputActions.Player.Move.ReadValue<Vector2>();
    4.         inputX = inputVector.x;
    5.         inputY = inputVector.y;
    6.     }
    Thanks in advance for your help.
     
  2. Beshi38

    Beshi38

    Joined:
    Feb 7, 2021
    Posts:
    5
    I solved the problem by changing the blend type from 2D Simple Directional to 2D Freeform Directional.

    I still don't understand why it worked perfectly on the y axis and not on the x axis.
     
    theacez likes this.
  3. theacez

    theacez

    Joined:
    May 15, 2023
    Posts:
    1
    I don't care if I am being a necromancer, Beshi, after over 2 hours of searching, I finally found this solution.
    This solved my issue.

    My left direction was only active if my x axis was less than or equal to the left value, otherwise, I was was getting by right, positive x animation.

    (Hopefully thus wording will make it more prone to showing up in Google searches for future --masochists-- learners