Unreal Looping Palindromic Animation with Root Motion

How to make Unreal Palindromic Animation loops with root motion using State Machines – (and there really isn’t any other way to do this so don’t bother with Anim Montages, Anin blending, Sequences or anything else, I have done so you don’t have to)

First I assume that you have gotten your anims to work with root motion (by properly fixing up the skeleton in Motionbuilder see here if you havent)

What we will do is make a blueprint character that uses an animation blueprint. Inside the blue print are 2 states, the animation forwards and the animation backwards (by setting play rate to -1). At the end of each anim, a transition rule jumps to the next state. How we do it is like this.

1. Make an Animation Blueprint

2. Inside the Animation R click and choose Add New State Machine – hook it up to the Final Animation pose, then dbl click it to go inside. (I called mine ‘Loopy’)

3. RClick drag off the Entry Node and choose Add State – this will hold your Anim. Mine is called ‘Anim 5‘.

4. Double click the State to go inside and hook up your first anim, in the settings set it to not looping. (see below)….

5.  You can click the words above the graph to navigate up one level – so to go up I click ‘Loopy’ on (see pic above)

6. Drag off a new State node from the first state. I called my second state ‘Anim5Backwards‘. Double click to go inside and add the animation again, set it to not looping but this time set the play rate to -1 in the settings. (Will make it play backwards.)

7. Now go back up one level. Now its time to set up the rules for transitioning.  Drag a line to connect the Anim5Backwards back to the Anim5 state -this will be our tight palindromic loop. The railway-logo looking bubbles are the transitions. Double click the top one to go inside.

8. Inside the transition Rclick and Add a Current Time Ratio. This gives (predictably) the current time of the anim as a ratio – so 1 = 100%. Hook this up to a Float>= and set the value to 1.

9. go back up and set the second transition up in a similar way except because this animation is playing backwards we want a Float<= with a value of 0 so if the anim is at the begining then transition. Like this

And thats it. The animation will palindrome correctly. The state machine seems like a really complex way of getting a ping pong effect but shortly we will use a state machine technique to transition from Anim A to anim B with a blend in between. (What the root motion gives us of course is the root of the anim which moves with the animation, so not only does the subsequent animation start in the correct position, but the animations will follow terrain up and down.