Search Unity

An example of what kind of code to use with blend trees?

Discussion in 'Animation' started by MasterElement, Jul 16, 2019.

  1. MasterElement

    MasterElement

    Joined:
    Jun 13, 2016
    Posts:
    140
    Okay so I have a idle, walk, and run animations, and I don't just want them to cut from one to the other instantly, I want to blend them during the transitions. I used UE4 before going to unity for 3d game creation, so I am all to familiar with the concept of blend trees. There is just one big difference between the design of the ones in UE4 and unity. That's is in UE4 when you create a blend tree it automatically blends the transitions of the animations. While unity just cuts from one to another with out blending them. So I know that to get it to blend on the transitioning of animations on the unity blend tree you have to use code. I have no idea what kind of functions you use in code to make it gradually transition, and as a result I couldn't find any examples on google. Can you guys help me out and show me an example of code to do that gradual transition of the blend tree? I would love it if I got a couple different ways to do so if possible.

    Now you can skip this art if you wish, but I understand how the code needs to go about the gradual transition just not how to actually code it. But I'm going to explain my understanding so you guys know what page I'm on or can correct it if I'm wrong.

    So it seems to me that without the code the blend trees parameter when they change from one amount to another just jumps to the new setting so the Animation and just cuts from one to another instantly. So I assume what the code needs to do is gradually over the passing of several frames increase or decrease the parameter to it's new amount so the animations slowly shift from one to another, is that right?