Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
1  
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. –  annonymously Jan 15 '12 at 21:27
    
Or linear interpolation with smoothstep, if you want a weighted average (: –  Gustavo Maciel Feb 11 '12 at 19:09
    
@Gustavo-Gtoknu can you explain more about what you just said? –  Asher Einhorn 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. –  Gustavo Maciel Feb 14 '12 at 0:22

2 Answers 2

up vote 9 down vote accepted

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 exists.

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.

share|improve this answer

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.

share|improve this answer
    
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. –  mallardz Oct 26 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. –  jhocking Oct 26 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. –  mallardz Oct 28 at 9:14
1  
ah yeah I meant sprite-based animation, I'll edit my answer –  jhocking Oct 28 at 15:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.