Game Dev

Automated foot sync markers using animation modifiers in Unreal Engine

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:
https://github.com/gportelli/FootSyncMarkers

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.

Code Analysis

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 GetBoneLocationRelativeToAtTime.

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.

Sample Project

Sample Project on GitHub

References

3 thoughts on “Automated foot sync markers using animation modifiers in Unreal Engine

  1. Valerie Henry

    Hey, so I was hoping to try out this tool but seem to have run into an issue with the project. When I open the downloaded project in engine version 4.16 the blueprint in the BoneModifier folder doesn’t actually show up. I can see it when I look in Windows Explorer so I know it is there, but not in the editor. Consequently, it doesn’t show up as an option to add when trying to Add Modifier in the Animation Data Modifiers tab. Do you have any suggestions?

    Reply
    1. Giuseppe Portelli

      Hi, this project requires UE 4.19, blueprint assets created with a newer version can’t be opened in an older one.

      Reply

Leave a Reply