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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Blend Tree always play the wrong motion for one frame after the transition.

Discussion in 'Animation' started by TitoOliveira, Jul 27, 2020.

  1. TitoOliveira

    TitoOliveira

    Joined:
    Aug 4, 2014
    Posts:
    77
    Here's a quick glance at my setup, it is a 2D game with fbf animations:

    upload_2020-7-27_0-27-31.png

    What i'm doing here is passing to the Animator system a facingDir float, which is always -1 or 1, wich means Left and Right. And then all my animation states are blend trees that select between LEFT or RIGHT animation based on the facingDir attribute.

    What i'm noticing is that the first frame after a transition between states the blend tree plays the wrong motion before playing the right one. I.E: If my character is moving RIGHT, then when the state machine transition to the Run animation, the blend tree will play the RUN LEFT animation for one frame, and readjust for RUN RIGHT the next frame onwards.
    This happens even though in the Animator the blend tree has the RUN RIGHT correctly selected and the facingDir parameter never changes to the wrong value, but for one frame the character playes the RUN LEFT one.

    Not sure if this is a bug or something particular to the blend tree. Either way i wanna know if there's something i can do to correct this behavior before redesigning my animation states to not use blend trees.
     
    NonSuspicious and h0neyfr0g like this.
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,491
    Calling animator.Update() would probably skip the bad frame, but that's a massive performance cost for something so simple.
     
  3. TitoOliveira

    TitoOliveira

    Joined:
    Aug 4, 2014
    Posts:
    77
    Tried just for the sake of it, but the issue still occurs.
     
  4. h0neyfr0g

    h0neyfr0g

    Joined:
    Jul 13, 2019
    Posts:
    35
    I am also running into this. I have an idle and an idle shooting animation, but one incorrect frame plays before the proper of the blend tree.
     
  5. NonSuspicious

    NonSuspicious

    Joined:
    Dec 20, 2021
    Posts:
    1
    Hi, I am also running into a very similar problem, just I have 2D pixel art sprites and when transitioning from attack animation to idle, the wrong frame plays(more in the middle of idle animation) and then it starts idle animation from start as normal... did you find any solution? If you did, please share it, it would be greatly appreciated!

    Best regards,
    NonSuspicious
     
  6. mkrymski

    mkrymski

    Joined:
    Oct 31, 2021
    Posts:
    1
    Same issue here :).
     
  7. PaulEbeling

    PaulEbeling

    Joined:
    Feb 12, 2022
    Posts:
    1
    Try to make the Transition Duration 0 and disable Exit time
     
    randyhuynh likes this.
  8. randyhuynh

    randyhuynh

    Joined:
    Jun 9, 2015
    Posts:
    2
    I had the same problem. I had Exit Time uncheck already, but didn't check under that for Transition Duration(s). Once I changed that to 0 from the default of 0.25, everything worked perfectly. Thanks, Paul!