# Animation Blending Basics

Say I have a framework with characters that can run and walk and of course, stand still.

Am I right in thinking that animation blending is the process of smoothly transitioning between these by generating dynamic animations at runtime?

If so, what is the basic theory of how this works, and how would I implement it?

• I believe it's just linear interpolation between each of the bones from the last frame of one animation to the first frame of the other. Jan 15 '12 at 21:27
• Or linear interpolation with smoothstep, if you want a weighted average (: Feb 11 '12 at 19:09
• @Gustavo-Gtoknu can you explain more about what you just said? Feb 13 '12 at 11:37
• you do a linear interpolation in alpha of both frames to be blended, on the inverse of the other. both in function of time. You can smoothstep or use a weighted average in the interpolation to have a different effect. Feb 14 '12 at 0:22

Character animation blending is more general and can be used for:

• Computing smooth transitions between 2 clips;
• Creating completely new animations from existing ones (potentially more than 2 at the same time);
• Achieving IK-like behaviors;
• etc.

The basic idea is that for two identical skeletons with different animation clips, for each joint rotation, you compute in-between values. Animation clips are represented with rotations. So linear interpolation is not what you should use if you want accurate results (even if you are using Euler angles). You can use slerp for example but more complex solutions exist.

This is a complex problem with complex solutions. Basically, if you have two animations clips A and B:

• If A and B are completely different (blending jump and swimming), then chances are you will have strange/funny results;
• If A and B are similar (two walking animation clips), then, you must first synchronize them to blend them when both left feet are on the ground for example.
• etc.

If you are interested, I suggest you start by reading this article so that you can better understand what the difficulties are: http://graphics.cs.wisc.edu/Papers/2003/KG03/regCurves.pdf

It is not the most up to date one, but it is easy to read.

I hope this helps. Best regards.

First off, I assume you are talking about skeletal animation (especially 3D graphics) since animation blending pretty much only applies to skeletal animation. If you are talking about 2D sprite-based animations (you didn't specify in your question) then you can pretty much forget about animation blending.

With that out of the way...

Am I right in thinking that animation blending is the process of smoothly transitioning between these by generating dynamic animations at runtime?

That is pretty much what the term means, yes. That phrase "generating dynamic animations" is a tiny bit misleading however; that brings to mind procedural animation and that isn't exactly what you're doing.

"Animation blending" is when you transition between two animation clips by using a bit of both animations with the weighting of one clip going up while the weighting of the other clip goes down. This works best with skeletal animation, so that the rotation of each joint is set to a midpoint between that joint's animation in two different animation clips, with the weighting of each clip changing over time. That is, you'd calculate the rotation of each joint something like:

rotCombined = weightA*rotA + weightB*rotB

Now, while animation blending works best with skeletal animation, you can also do it with vertex animation (eg. MD2). This is more of a historical note because few modern game engines use vertex animation, but you can set the vertex positions in the same way, as a weighting between the vertex position in two different animations. This could result in some weird looking interpolations (eg. parts of the mesh collapsing or turning inside-out) if the two animations were too different, whereas skeletal animation ensures that the various parts of the mesh stay whole.

• When you say you can't do this with 2D graphics, do you mean sprite based animation? I'm trying to find out how to blend some 2D animations created in mecanim based on position & rotation of individual body parts, but I don't see why it's not possible just because they are 2D. Oct 26 '14 at 13:39
• Because there's no way to generate new frames in a sprite animation. In 3D animation, the individual images aren't generated ahead of time. Oct 26 '14 at 14:22
• I get it, but 2D animation doesn't have to be solely based on changing the entire sprite. You could compose an object out of multiple sprites and animate their rotation and position etc. I was trying to find out how to do this when I read your answer, and your first line made me sad :( ! But luckily it turns out it's very easy to do in Unity and I imagine no more difficult than 3D blending for those who roll their own engines. Oct 28 '14 at 9:14
• ah yeah I meant sprite-based animation, I'll edit my answer Oct 28 '14 at 15:23