Root Motion

The information on this page applies the same whether you're using Animancer or regular Animator Controllers and the redirection scripts are included in Animancer Lite so feel free to just grab them if you aren't using Animancer.

What is Root Motion?

Regular Animation Root Motion
Animations normally set things to a specific value. For example, a movement animation might start the position.z at 0 and move it to 1 over the course of the animation, but then when the animation loops it will teleport back to 0 again. Root Motion changes any movement that would normally be applied to the root object to be additive instead. So if your position.z is at 4 and you play that animation it will it will add the motion so it moves towards 5 then 6 then 7 and not jump back to the starting value when it loops.

How to use Root Motion?

If an animation includes movement on its root bone, Unity allows you to turn it into Root Motion in that animation's import settings:

  • It has 3 separate categories of Root Motion: Rotation, Position (Y) for vertical movement, and Position (XZ) for horizontal movement.
  • Having the Bake Into Pose toggle disabled for a category will allow that aspect of the animation to be used for Root Motion.
  • With that done, the Apply Root Motion toggle in an Animator component will determine that motion is applied or ignored.

Apply Root Motion Off Apply Root Motion On

When to use Root Motion?

Root Motion gives artists control over the character's movements instead of having programmers move everything in scripts. This can be good in some situations and bad in others:

  • If the motion is not constant, using Root Motion can allow it to be more realistic. For example, stepping forward while swinging a weapon would probably have you moving forward at the start of the animation but then being mostly stationary or even stepping back towards the end of the animation.
  • If precision is more important, avoiding Root Motion might be better. For example, in a top down game players are less likely to focus on specific foot movements like that and a multiplayer game might want to have a dedicated server which can simulate everything moving at whatever speed their stats say without even needing to have character models or animations loaded at all.

Even if you do use Root Motion in your game, that doesn't mean you need to use it for everything. Generally, animations like Idle should have the Bake Into Pose toggles enabled to ensure that they don't cause even a little bit of Root Motion.

As a real life example, the world record in the low% speedrun category in The Legend of Zelda: Twilight Princess currently involves doing nothing for over 17 hours (real time) while an animation that should be stationary actually applies a very small amount of root motion which eventually allows the character to clip through a wall.

Layers

When using multiple Layers, Root Motion behaves pretty much the same as the rest of the animated properties:

  • By default, the highest layer overrides lower ones.
  • An AvatarMask can disable Root Motion from a layer so that the one below it will take effect instead. For Humanoid Rigs, that's controlled by the circle at the bottom of the mask.

Redirecting Root Motion

It's usually a good idea to keep a character's logical components separate from their model for organizational purposes, so you might have a hierarchy like this:

In that case, the Animator will apply any Root Motion to itself by default, causing it to move away from the Collider and Rigidbody if they aren't on the same object.

Animancer includes several scripts which solve this problem by redirecting the Root Motion to a various different object types.

Default Root Motion Redirected Root Motion

To use these components, simply add one of them to the same object as the Animator and set its Target to the object you want to apply the Root Motion to. If a component of the Target type is on a parent object, it will be assigned automatically.

Component Redirects To
RedirectRootMotionToCharacterController CharacterController
RedirectRootMotionToRigidbody Rigidbody
RedirectRootMotionToTransform Transform

Those scripts are located in Packages/Animancer/Runtime/Utilities/Redirect Root Motion and have no external dependencies so feel free to just grab that folder if you want to use them without Animancer.