Animation Blending

Animation Blending refers to in-engine transitioning and mixing between two or more skeletal animations. This is generally achieved by a finite state machine, often referred to as an "animation tree" in this context. The purpose of the animation tree is to hold all possible animations of a character, define how they blend and transition (typically via a node graph), and receive calls from the character controller to determine the desired transform of all bones. If you are a 3D animator as part of team and do not deal with animation trees yourself, it is still important to understand the basics of how they work so you can provide animations that transition and blend properly.

Blending Different Walks

YY2NdrI.jpg

fig.A - The correct keyframe to begin a walk cycle on


When you're animating your character's walk and run cycles, it's important to always ensure the character steps forward with the same foot. Whether left or right, all walking/running/sneaking etc. animations should match whichever foot moves forwards first. This allows you to smoothly transition from one cycle to another, or even cleanly mixing two cycles together to generate, for example, a character that incrementally ducks higher or lower under variable height low ceiling (via blending walk with crouch walk).

Another common mistake is starting walk cycles with the feet fully extended in the step. It is a much better idea to begin a walk cycle on the keyframe where one foot is vertically aligned with the body, and the other just about to pass by (see fig.A). This way, when transitioning from an idle stance to walking, the character's feet will move smoothly into the stride rather than oddly jumping forward and back.

2πr (360º) Directional Movement

There are a number of ways to achieve directional character movement whilst maintaining a separate facing angle. This article will cover two methods I developed after studying various examples in 3D video games. The examples below provide description merely for walking, but obviously they can also be applied to running, sneaking, etc. Angles will be expressed as radians as that is the standard in nearly all game engines.
OoT_ZTarget.JPG

Ocarina of Time's Z-Targeting, which allowed the player to move independently from facing direction

turn_anim.png

fig.B - The Turn animation.

Solution1_Visualization.png

fig.C - Solution 1: Movement Angles

Solution2_Visualization.png

fig.D - Solution 2: Movement Angles

Solution 1 - Simple 2πr Walking

The simplest solution uses merely two animations. A walk animation (which is reversed for walking backwards; you can optionally make a seperate one) and a Turn animation (fig.B). The turning animation starts with the feet facing right, transitions to a standard forward stance, and ends with the feet facing left. Ensure the animation's keyframes are equidistant, use linear interpolation, and that you only apply keyframes to the spine and neck. If your animation exporter requires all keys be framed, ignore all but the described bones in engine. This will be very important when blending. Blending 2πr directional walking is done thusly.
Forward Hemisphere: Combine the Walk animation with the Turn animation using Additive blending. Using the character's 2D horizontal movement vector, set the time of the turn animation to match the angle they are moving— given that θ is the movement angle in radians, the simple formula $[θ + π ] /2π = T$ provides a value between 0 and 1 which can be then multiplied to actual the length of the Turn animation.

Backward Hemisphere: Simply play the Walk animation in reverse (or play Walk Backwards), and inverse the time of the Turn animation relative to the angle of the movement angle: $1 - [θ + π ] /2π = T$
Blending Between Forward and Backward: Give yourself a small buffer zone(shown as green in fig.C; exaggerated for visibility) around 0.01r, and when the movement angle extends beyond that buffer, trigger a transition from one to the other in the animation blender. This way you will not have constant unecessary transitions if the character is moving directly left or right.

Solution 2 - With Sidestepping

Adding side stepping animations complicates things only a bit in theory, but can be more of a headache in code. Of course you will need a sidestepping animation (two, if your engine does not support mirroring animations) and we will need to add zones (fig.D - shown in red) to our circle that will trigger a transition to sidestepping, left or right. We should still use buffer zones to prevent constant transitions. When the player angles past a buffer zone, transition into one of the four possible animation branches - forward, sidestep left, sidestep right, and backward. Suggested values are shown.

Animating Movement on Slopes (in progress)

WpgIQHI.gif

fig.E - A flat walk blending incrementally towards an ascending walk


Adding the extra detail of providing unique movement animations for traversing up and down slopes is fairly simple, but you will need to add two more animations for each walk cycle you use it with— one for walking up and another for walking down. Bear in mind this is not analogous to IK feet positioning, though you'll likely want to use that in conjunction with slope traversal animations for best results.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License