How to move character or actor to simulate root motion

I think that the best practice for root motion in animations is the root bone, but say I know the relative location change in the animation movement and I want to snap my character to wherever the animation ends anyway, what’s the best way to simulate root motion so that the movement keeps the correct velocity and direction relative to the world.

I got it working well enough.

  1. Preparation steps - Have two copies of the same anim, (a) one that does not move along the x and y or wherever the major movement is(I deleted the key-frames in blender), and (b) one that does, but snaps back after it finishes(the entire problem in the first place)
  2. Give them both anim_notifies on their final frames
  3. Set anim (b) as the “data anim” in the state machine, and anim (a) as the “actual anim for final use” in the state machine with respective activation booleans.

  1. Set it up so the end Notifies call both the deactivation of the booleans, and custom events in the character blueprint.

  1. Set up a blueprint script that is only run once in the editor to gather an array of floats used to drive acceleration of the movement component, also make sure to expose the “distance between ticks” array.

  1. Set up the actual blueprint nodes that move your character while the animation plays, for now my setup supports backward movement as long as it does not go past the starting point.

  1. Now play in the editor and activate your data anim, you should be on a flat plane, and the anim should snap back to where it started when it finishes, I used “I” on the keyboard. Do this only once.
  2. Then press Shift F1 to eject your mouse from the editor while it is still running and find your “distance between ticks” array in whatever actor you have it in(the world outliner tab), it should have more than 0 elements if everything went smoothly. Now right click on the elements of that instanced array and “copy”

  1. Now exit playing in the editor and go back to your character blueprint, find your “distance between ticks” array and paste the elements where the array’s default value is. Picture will be in comment below.
  2. You can now disconnect or delete the gather data stuff as this entire process was to get those array elements, also disconnect your data anim and only use the one that does not move along x or y, as the movement driver will simulate the root motion
  3. You should also set up some booleans to disable input during the anim, make it so it does not activate when you jump, tweak the ‘max walk speed’ so it plays back well, and you should be done.
  4. Is there a high chance this was totally unnecessary, oh yeah, but fun, and good practice.

Where to “paste” picture

I found a better way to interpolate between the array elements for varying frame rates instead of my “Move_SV_Index” node off the “Movement Driver” timeline. I instead get the frame rate when you activate the anim, then divide the FPS that the array was captured in(array length(71) / anim length(1.167 secs)) by this current FPS, then I add this value to itself and floor it so that my array plays every “nth” element which seems move my character during the animation to the same place regardless of FPS, tested at 10, 30, and 60 FPS.

I assume this works because the “Add Movement Input” node moves the character across a smaller distance per frame at higher frame rates and vice versa.