- Home /
Are mecanim blend trees linear?
Hey there people,
So I was looking into manipulating movement speed of a character in mecanim, and someone suggested using a blend tree of the same animation in different speeds and blend between them using a float that I can set from the script, sounds good.
The thing is though, I set my blend tree to 1D blending, from 0.5 to 2. Accordingly I set my animation speeds to 0.5 for the slow one and 2 for the fast one.
It seems that the end points work correctly, 0.5 and 2 indeed result in a corrent animation speed.
but 0.5 is actually 50% movement speed of my character, so most of the time the float is set to 1, and I expected the animation to blend linearly and get a value of 1.
I don't know if I'm missing anything, but to me it seems that the animation is slower than that. That also suggests that the blend tree isn't blending linearly, which seems wierd.
Anyone got an idea?
Thanks ahead.
[SOLVED]
Hey there,
thanks for the answer, I'm aware of what you talk about, that's not what I was trying to achieve.
I did solve the issue though, the thing is, the blending is indeed perfecrly linear as it should be, it is I who needed non-linear result, and now I see why.
The relationship between my float variable and my animation speed is a variant of y=m/x and not y=mx+n
I realized that when I was looking at the amount of frames it took the animation to play under different values of my float variable.
at 0.5 it took 30 frames.
at 1 it took 23 frames.
at 1.5 it took 15 frames.
at 2 it took 7 frames.
As expected, perfectly linear. BUT, what I needed is that at a value of 1 it would already play only 15 frames, 50% of the amount of frames it took 0.5 to play (30).
Then I realized that I need to pass not X to y = mx + n, where y is the animation speed.
But X so that my linear function will turn to y = m/x.
So I had to pass y = m(a) + n, where a = 1/x - n/m.
That way I can pass a non-linear represntation of my animation speed and get the linear blending act like I want it to, non-linear behaviour.
That works for me, hope it helps someone, that perhaps has the same issue :)
Answer by Void24 · Feb 10, 2014 at 10:48 PM
I don't think there is enough information here to be able to tell exactly what is wrong, but I will make my best estimate.
Keep in mind that 1 is not halfway between 0.5 and 2. If your slow animation is at 0.5 and fast at 2, expect a value of 1 to be a blend of 66% slow animation and 33% fast animation. This would be the correct linear blend.
Set your Fast animation at 1.5 if you want a value of 1 to be a half and half blend.
Answer by Vicomte · Feb 11, 2014 at 12:26 AM
Hey there,
thanks for the answer, I'm aware of what you talk about, that's not what I was trying to achieve.
I did solve the issue though, the thing is, the blending is indeed perfecrly linear as it should be, it is I who needed non-linear result, and now I see why.
The relationship between my float variable and my animation speed is a variant of y=m/x and not y=mx+n
I realized that when I was looking at the amount of frames it took the animation to play under different values of my float variable.
at 0.5 it took 30 frames.
at 1 it took 23 frames.
at 1.5 it took 15 frames.
at 2 it took 7 frames.
As expected, perfectly linear. BUT, what I needed is that at a value of 1 it would already play only 15 frames, 50% of the amount of frames it took 0.5 to play (30).
Then I realized that I need to pass not X to y = mx + n, where y is the animation speed.
But X so that my linear function will turn to y = m/x.
So I had to pass y = m(a) + n, where a = 1/x - n/m.
That way I can pass a non-linear represntation of my animation speed and get the linear blending act like I want it to, non-linear behaviour.
That works for me, hope it helps someone, that perhaps has the same issue :)
Your answer
Follow this Question
Related Questions
UnityEditor.Animations.AnimatorControllerLayer.SetOverrideMotion not working 0 Answers
Leg crossing while blending strafe animations? 0 Answers
U4.3.4: Mecanim blend trees, no more old docs? 1 Answer
mecanim animation runs at random speed on iOS 0 Answers
Mecanim - changing animation clip speed, through script? 4 Answers