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

6 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
  2. Tala Esenlikler

    Hello, when i try to move these events it says something like 0.0001 is not a valid time. What could be the possible problem?

    Reply
  3. theseascout

    Hi, this is really great, thank you.

    FYI, there is a bug in UE4.25 where notify tracks created by animation modifiers will not initially appear in the editor when the modifier is applied to individual animation sequences (They do appear when you apply the modifier to a skeleton asset). The Notifies are actually there though, you have to collapse and expand the Notify track list to make them visible.

    https://issues.unrealengine.com/issue/UE-96789

    Reply
  4. Russell Stenberg

    Thank you. Thank you. Thank you, I was beating my head on my desk for a day trying to figure out how to get the relative location of a given bone at a given time through an anim modifier. Turns out to be a lot easier than I thought.

    Reply

Leave a Reply to Tala Esenlikler Cancel reply

Your email address will not be published. Required fields are marked *