Root Motion

Typically in game animation, a character's collision capsule (or other shape) is driven through the scene by the controller. Data from this capsule is then used to drive animation. For instance, if the capsule is moving forward, the system then knows to play a running or walking animation on the character to give the appearance that the character is moving under its own power. However, this type of motion is not always ideal for every situation. In some cases, it makes sense for complex animations to actually drive the collision capsule, and not the other way around. This is where Root Motion handling becomes critical for your games.

Consider, for example, a special attack from a player in which the mesh had been pre-animated to lunge forward. If all character motion was based off of the player capsule, such animations would cause the character to step outside the capsule, effectively losing collision. Once the animation had played out, the player would slide back to their collision location. This would be problematic, as the capsule is generally used as the center of all calculations. Characters outside their capsule will pass through geometry and would not react properly to their environment. Plus, the slide back to their capsule at the end of the animation would be unrealistic.

For those new to the concept, it may not be readily apparent why proper Root Motion would be important from just reading a description. Below, we have a character that is performing a pre-animated attack in which he lunges forward and slams down a hammer. Be aware that the animation of the character moving forward was not handled in game - it was created that way by an animation artist.

See the Animation Content Examples page under section 1.9 for another example of Root Motion.

What Is Root Motion?

Put simply, Root Motion is the motion of a character that is based off animation from the root bone of the skeleton. Most in-game animations are handled via cycles in which the character's root remains stationary. This cannot always be the case, however, as we can see in the example above. To handle this, we need to take the motion of the root away from the character and apply it to the character's capsule instead. That is the essence of what Root Motion does in UE4.

In order to properly use Root Motion, it is important to note that the Root Bone of your character should be at the origin (0,0,0 with no rotation) as this allows the system to isolate physical movement (capsule) from animated movement (character).

The Root Motion of an animation can be visualized during playback. Simply open up any animation in which the root bone is moving, and in the viewport choose Show > Bones. If you have not selected Enable Root Motion in the animation properties, you will notice a red line that appears as the character's root moves. This illustrates the Root Motion of the animation.

RootMotionBone.png

When you enable Root Motion, this red line will disappear. Instead, the character will move in place. This is beacuse, the character's root will no longer move from its original position. In this image, we have enabled Root Motion on the character. Note that we are on the same frame as the image above, but that the character's position has not changed.

RootMotionAppliedBone.png

So, what does this mean? Now that the system is taking the Root Motion of the character's animation into account, it is then able to reapply that same motion to the character's collision capsule. This means that it can still have the exact same motion that the animator intended, but it can also respond properly to in-game collisions and other physics and gameplay events. We will see this in action in the section below.

Enabling Root Motion

Root Motion can be enabled inside the Asset Details panel in the Animation Editor for your Animation Sequence .

RootMotion.png

Early versions of the engine (Versions previous to 4.5) required the use of an Animation Montage to define Root Motion. Since version 4.6, Root Motion is now handled per Animation Sequence and can be toggled on/off in the animation's properties in Persona. For networked games however, Root Motion still requires the use of an Animation Montage, see Root Motion from Montages Only below.

While defining if Root Motion is enabled in done inside the Animation Sequence, you will still need to determine how that sequence is handled inside of an Animation Blueprint . There are several different ways in which you can handle Root Motion within Animation Blueprints. You can define this through the Root Motion Mode drop down in the Details panel of the Anim Blueprint Editor.

RootMotionMode.png

The options are as follows:

Property Description
No Root Motion Extraction Root Motion is left as is (applied to the root bone).
Ignore Root Motion Root Motion is extracted (and removed from the root bone), but not applied to the character.
Root Motion from Everything See Below.
Root Motion from Montages Only See Below.

Root Motion from Everything

When this option is set as the Root Motion Mode, each animation asset (AnimSequence, Blendspace, AnimMontage, etc.) that contributes to the final character pose has its Root Motion extracted (if it has been set as containing Root Motion). Each piece of extracted Root Motion is blended based on the weight of the source assets contributing to the pose.

For example:

FromEverything.png

In the image above, the Root Motion of Jog_Loop_Fwd_RM and Jog_Loop_Right_RM would each be blended together with a weight of 0.5. The resulting animation in this case is a character running diagonally forwards and right across a map.

Root Motion from Montages Only

This method is intended for network games which is the reason for its more restricted functionally. Because Root Motion from Everything is designed to be unrestricted, it is recommended that it only be used in games where animation isn't replicated over a network.

Root Motion in Action

Below is a breakdown of the problems with not handling Root Motion, and the benefits Root Motion has on your animations. We will be using the lunging animation shown above.

Without Root Motion

Without Root Motion, such animations would pull the character away from his capsule, as seen below. Note the unsightly snap back to the capsule location. This happens because once the animation is done playing, the character controller pulls the character back to their original position.

Why Capsule Separation is Bad

And the snap-back problem is not the only issue to fight in this case. Since the character is leaving the collision shape, it will pass through world objects and break overall continuity. In this example, we can see the character's attack makes him go through a wall and then jump back.

How Root Motion Handling Solves the Problem

Once your animation is set up to utilize Root Motion, then the movement that was set up by the animator temporarily becomes the driving force of the capsule. This allows us to continue playing from the end point of the animation. You can see that the second time we trigger the attack, we take off from the new position. Of course, we turned around first so we did not wander off camera.

Root Motion and Physics

Since the capsule comes along, this means that physics collisions can still be used and we solve the issue of characters passing through walls, as well as alleviating the problem of the character needing to snap back to the capsule position. In the image below, the animation is using Root Motion, which brings the capsule along, causing the character to collide with the wall, rather than passing through it.

You will note that it is not quite perfect, as the character's bending animation causes it to pass somewhat through the walls. However, this could be easily managed by either working with collision volumes on either the wall or the character. The important point is that the capsule is keeping up with the motion and preventing the character from passing all the way through the wall and having to snap back.

The physics state of the Character is taken into account during Root Motion. For example, if the character physics is Walking or Falling, then the Z-axis of Root Motion will be ignored, and gravity will be applied. Characters will fall, go down slopes or up stairs. If the character physics is Flying, then the full Root Motion is applied and gravity is ignored.