I've done some more work on the animation system recently so I thought I'd change gears slightly and write about that today.
You will have noticed in the previous video I posted that the robot's animation transitions are very sudden and don't look very natural (even for a ridiculously proportioned robot). The remedy to this is animation blending, whereby two or more animations are smoothly blended during a transition phase. This has been on my to-do list ever since implementing skeletal animation so I've finally gotten around to it.
The first place I turned to for implementation details was the book Game Engine Architecture by Jason Gregory (which I highly recommend). Chapter 11 contains a wealth of practical information on implementing animation systems.
The first change required was to store keyframe data in scale/rotation/position format (also known as "SQT") instead of matrix format. The reasons for this are; a) it's smaller, b) it's impractical to blend between transform matrices. The second was to implement a global time line scheme when dealing with the animation clips (also detailed in the same chapter). I won't go into my implementation as it's still quite rough at this stage and bound to change but definitely check out the book if your interested.
With that in place, a short transition between animations made a big improvement but you can go one better. Linearly blending between animations doesn't take into account any of the twelve principles of animation and makes for frowny animators (in this case, me). By blending in additional transition clips you can create much more interesting animation behaviour. In this case I've added a transition clip to the start and finish of the walk cycle.
- idle to walk transition: This one's very quick as the character needs to start walking straight away. It basically consists of a slight anticipatory body dip and also starts the limbs moving.
- walk to idle transition: A longer animation used to help settle the character back into it's idle pose. There's a slight body sway as the torso comes to rest and the arms swing forward to follow through after the motion of the walk. This helps to convey a sense of weight to the character.
The in game results can be seen in the video below.