Here are some things to keep in mind while working with root motion:
- Root motion will be ignored on the Z axis unless the movement mode is set to ‘Flying’.
- Root motion only runs from a montage by default and this default should not be changed in a networked environment. To change the default the setting can be found in your Animation Instance.
- If you’re using a montage it will run from an animation slot which needs to be connected in the animation graph.
These are the steps that should get you started.
- Export an animation with movement on the root bone
- Import it to UE4 and open up the animation to set the option “Root Motion” (enabled checkbox)
- Setup your montage if that’s your chosen method for playing your root motion animations
- When input is received, set the CharacterMovementComponent to “Flying” with “Set Movement Mode”.
- When input is received for the jump, trigger the animation, if you’re using a montage you can call Play Anim Montage directly from your Character blueprint, if you have root motion enabled without the use of a montage you can get the mesh component → Play Animation, alternatively you can use C++ to expose the method
PlaySlotAnimationAsDynamicMontage()
however I wont cover that, that would be better saved for a google search or a separate question. - You’ll need a way on completion to stop it from flying when the animation has completed, the easiest way IMO to do this is to use the node
Get World Delta Seconds
+ the length of the animation and store it on a variable that you check on tick, that will give you a ‘time’ when the animation will have completed, then on tick you can check ifGet World Delta Seconds
is >= that stored variable, and change the movement mode if so. Alternatively you can use anim notifies but that’s covered elsewhere.