Additive Root Motion


In the game files I am working with, the animations used for moving the camera encode the motion of the game object. This is supported by bs::f, but only for perfectly looping animations.

I have a human character with an animation for running forward. In the animation, the character will run a few meters towards the X-axis. Then it is reset back to zero as the animation goes into the second loop.
In the original game, the delta in position between animation frames was added to the objects position, except for the final jump back to zero.

Right now, in bs::f, the animation is played correctly and the position of the root node is transferred correctly to a scene object, but it does also reset back to zero as the animation is looping.

I hope I explained it so you can understand what I mean. If so, is that something bs::f supports or should support?


If I understood correctly, I believe MeshImportOptions::importRootMotion import setting + AnimationClip::getRootMotion is the settings you need.

You should enable MeshImportOptions::importRootMotion when importing your animation clip. This will stop bsf’s animation system from moving the root bone.

Instead you will be given a RootMotion object, accessible from AnimationClip::getRootMotion. From this object you can access the root animation curve directly. Using this curve you can move the character’s scene object manually, from Component::update.

A system that does this internally might also be an option, but looping root motion is usually applied to characters (from my experience), which also need to respond to obstacles and is best left to the user.


Since I have to import my files from a custom container format, I cannot use the importer classes directly, so I’m constructing the objects by myself. That RootMotion object seems to be exactly what I need, too. I’ll try to make it do what I want, thanks for pointing me to it!