Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.14
more ▼

asked Feb 09 '17 at 08:19 AM in Using UE4

avatar image

Rez Nov
20 8 10 11

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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.alt text

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

  5. 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.alt text

  6. 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.alt text

  7. 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.

  8. 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"alt text

  9. 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.

  10. 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

  11. 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.

  12. Is there a high chance this was totally unnecessary, oh yeah, but fun, and good practice.

animgraph.png (218.8 kB)
animeventgraph.png (250.0 kB)
getdata.png (550.5 kB)
actualanimplay.png (703.4 kB)
copydata.png (311.0 kB)
more ▼

answered Apr 13 '17 at 02:41 AM

avatar image

Rez Nov
20 8 10 11

avatar image Rez Nov Apr 13 '17 at 02:42 AM

Where to "paste" picturealt text

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.alt text 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.

pastedata.png (244.5 kB)
arrayfps_s.png (274.4 kB)
(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question