Unreal Engine 4.16 introduced Animation Modifiers, a type of native blueprint class that enable users to apply a sequence of actions to an animation sequence or skeleton asset. In this article I will show you an example of animation modifier blueprint and a sample project which allows you to add foot sync markers and foot position curves to animation sequences as you can see in the following video.
Here is the sample project with the animation modifier blueprint described in this article:
Feet Animation Modifier Blueprint
The animation modifier blueprint is located in the
BoneModifier folder of the sample project and is called
FeetAnimationModifierBP. This modifier will add a track to your animation sequences containing sync markers indicating the instant in which each foot passes the pelvis line. The script can also generate curves for each foot containing the distance from the pelvis axis at each frame.
Let’s see the script’s UI.
- Path Filter – This option is useful if you are applying the modifier to a skeleton. It allows you to apply the actions only to the animation sequences with a path containing Path Filter. If you want to apply a modifier to all the walk and run sequences, for example, just put them in the same folder and set the Path Filter to the folder’s name.
- Root Motion Direction – The script computes foot distances from pelvis axis line in the direction of the root motion. You have to set the direction along which your animation sequence is moving.
- Create Curve – Check this if you want to generate foot-pelvis distance curves.
- Pelvis Bone Name – The name of the pelvis bone in your character’s skeleton.
- Foot Bones – An array containing descriptors for each foot you want to analyze (the script works with any number of feet).
- Bone – The name of the foot’s bone.
- Offset – An optional offset to add to the pelvis-foot distance to fine tune your markers and curves.
The script is pretty straightforward, it creates a track and some curves on the Apply event, then it cycles through all the foot bones and evaluates pelvis-foot distances for each frame, feeding the sync marker track and curves tracks with data. The only interesting part is the utility function
Use your mouse to navigate this blueprint or watch it at Blueprint.com
When getting bone transforms using
GetBonePoseforTime blueprint native function, the transform data will be in local space. Unfortunately if you need it to be in component space, you will need to manually convert the transforms. That’s what my function is doing: computing a bone transform relative to another bone at a given time in the animation sequence.
The function uses the
FindBonePathtoRoot blueprint native node to get all the bones which connect a given bone to the root in the bone tree. Once obtained the bone chain, it composes the bone transforms starting from the leaf bone and stopping at the reference bone. It is important to compose transforms traversing the tree from the leaf to the root; this guarantees to apply all parent transforms to each bone in the chain.