I’m using the Root Motion Guide plugin from the marketplace – it’s a paid plugin by Ju Sik Lee, it’s only about GBP40, and it’s great.!
After installing, make a copy (for safety) of any mocap animation you want to add root motion to and append RM to the end of the file name. The plugin has many other handy features, including a mocap trimmer and so on. In Unreal open the mocap file, then open the Animation Sequence window. Then in main menu, look under Window/RootMotionGuide Tools, choose Root Motion Extractor
This opens a floating window that needs to be docked into the AnimSeqence window
Drag the Anim sequence you want to extract motion from into the Anim Sequence slot, select the skeleton Pelvis bone, scroll the animation to get the Pelvis first and last frame Z heights, and enter into the correct boxes. Everything else I left as default.
Now hit Extract. If there’s a warning that the bone already has root motion, tick the Force Root Motion Extraction checkbox. And hit it again – it should bring up a successful dialogue.
((Note for whatever reason my Anims don’t have the root under the hips its at the origin of the mocap space.))
Now when you play the anim, the Pelvis stays in place. If you Check under the Asset Details and untick Enable Root Motion and Force Root Lock, you will see a red line from the root bone to the origin -this is good!
Now Enable Root Motion, Enable Force Root Lock AND set Root Motion Root Lock to Ref Pose..
REMEMBER TO SAVE!
We can PREVIEW how it will look in the 3d window by enabling Character/Animation/Loop. Now the anim will play and the root will move around.
At the end of the loop, the anim will jump over in space so the root at the first frame is at the last frame’s position.
However, the pose of the character’s limbs will be wrong, causing a visual pop.
We can fix this with a blend, but it helps if the start and end poses are somewhat similar. (The facing direction doesn’t really matter. It’s really the limb position – jumping from a bent-over pose with hands together to standing up with limbs apart will be quite a change. So, for this reason, sometimes its good to get the mocap performers to start in a ‘neutral’ position and return to a similar pose at the end AND potentially match the speed – I’m using long mocap takes of over a min of contemporary dance so my needs may be different to yours. )
REMEMBER TO SAVE!
So the next thing to fix is the root moving up & down in Z. I believe because the movement has come from the Pelvis – it gets vertical movement too. This won’t work so well but there’s a tool called Make Linear Root Motion Height. This flattens the vertical movement between the first & last frames.
Now we have to get the animation to loop, here are two methods.
Getting a single animation on a character to loop seamlessly: 2 methods
1. State machine
2. Flip Flop
1 State Machine
First we have to make a copy of the animation. Then we make an Animation blueprint. Inside we use a state machine that looks like this:
Inside the state machine, two states transition into each other. In Clip1, there’s the first anim clip, in the second, there’s the copy of the anim clip.
Unfortunately, this is not super efficient.
Each state has its anim set to not loop
And each transition has a TimeRemaining for its anim clip. If you copy the nodes, you’ll need to delete the TimeRemaining and add a new one so it updates with the correct animation. The idea is when there is one second of the clip left; it starts blending into the next clip.
This is how I’ve got the transition blend -its only 0.5-second blend, as my clip start and end poses are very similar.
Most importantly, in the Class Defaults, the Root Motion Mode must be set to Root Motion From Everything.
Now if you make a character and give it this animation blueprint, the clips will seamlessly blend with the incoming clip starting at the end position of the previous clip.
2 Flip Flop
( This method is from MATT3D )
Add an Anim Notfiy at the loop point on the animation
Make an Animation Blueprint, and in the Event Graph, search for Event AnimNotify<YourNotify>
Then add a Boolean variable mine is called Loop and set it like this. This sets Loop to the opposite of whatever it is every time the AnimNotify is triggered.
In the AnimGraph, add two copies of the AnimationSequence and a Blend Poses by bool.
Then hook up the Loop bool. The AnimationSeqence must be set to loop.
It’s possible to unset the Hidden in Game for the capsule to see it move around in the editor.
In the 3D viewport, enable Developer /Bones for debugging.
Getting several rooted animations to play randomly on a character and blend
This is developed from a technique suggested by Le Scylardor
You can use an Animation blueprint with a Random Sequence Player but I think the blend doesn’t work well, it blends in, but not out. It’s hard to tell and wont work well for me.
So this this method:
– firstly each Root Motion (RM) animation has to have an Anim Notify at least 1 second before the end, each notify called the same name e.g Blender
Then in the Anim Blueprint do this. In the Event Graph set up two integer variables and another called Max Anims Minus 1
– set this to 1 less that the number of animations you want to randomise. I have 3 anims so I set this to 2. This first part sets both variables to a random value, for starting animations.
Then do this.
Make an Anim notify called whatever notify name you used. Mine is Blender and its called whenever the notifiy is hit.
The logic is we set it to the opposite value when the notify called.
The default value of the Blend bool is false, when called it gets set to true.
The code after the Flip Flop alternates between resetting the two integer variables.
(This will make sense in a minute)
Also in the Anim Graph is this part.
First we set up the Select nodes…When you place a Select node the Option types are wildcard. Right-Click on Option 0 , change pin type to Anim Sequence / Object type.
You can Add Pins for each anim you have.
For each Option in the Select node put one of your anims.
Add a Sequence Player, under Details/Sequence click where it says Bind, choose Expose As Pin the Sequence, now you can hook it to the Return Value of the Select node.
Set the Sequence player to loop so its resets after its done.
This idea is that initially the Blend bool is False, so the bottom sequence player plays a random animation from the Selector. When the playing animation hits the Notify it triggers AnimNotify, which sets the Blend Bool to its opposite value (true), and chooses a new random value for the Current integer. The Blend Poses by Bool blends to this incoming animation.
Every time the AnimNotify is triggered (1 second before the end of the animation) the FlipFlop chooses a new Anim to blend to and blends. I have set my TRUE and FALSE blend time to 1 second which is why my notifies are set to at least 1 second from the end.
Thats it. you can probaly think of other ways to do this and also extensions for example blending between A and B sets of animations.
DRAFT More Advanced Root Motion extraction using a custom Control Rig to get the Root under the Pelvis– NOTES
Root Motion Animated that is set under the Pelvis and follows the Pelvis rotation. The Root Z height stays at 0, and the Animation Root starts at 0,0,0 position with 0 rotation. (Blending a set of animations will see a better result if all takes have the root rotated to face the same direction and at 0,0,0)
Place Character in the scene at 0,0,0
Make a level sequence
Add Character to LS
Add animation to the LS (the anim you want to root motion)
Adjust the end point of LS to the length of anim
Bake it to the special Control rig, then Rclick on the animation track and set ACTIVE.
- Now, the control rig will be able to keyframe the animation.
The red arrow shows the orientation of the Root. (My Root is at -90 (pointing right when the Character faces forwards) for whatever reason -probably to do with when the character was imported. This means that i want all the motions i want to blend to have this same orientaton, others may be different We need to add keyframes to set this up thru the sequence.
Open the Sequence curves.
Select all keys in the rotation root Z track and delete (graph-like button)
Activate the ‘Key when something changes’ button (key-like button)
scrub thru’ the sequence and add keys to get the Root pointing correctly
Select all the root positions from the pelvis keys and delete. This will get all the root Z positions to zero rather than following the pelvis.
Now bake the animation to a new file.
Now we will open the animation sequence and use the Root Motion Guide tools
first, use the Adjust Animation track to adjust the Root pos to 0,0,0. -Scrub anim to frame 0, select the root, copy the X and YZ position and use the inverse of those values in the Adjust Animation track, e.g. (X=-97.449478, Y=5.158674, Z=0.000000)
Hit Apply, and it should jump into position
Then check it, save it.
Now use the Rotate Animation Track tool to do the same for the root rotation.