Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SteveFSP · May 29, 2014 at 06:04 PM · animationanimatorroot motion

Handling Build-up of Root Motion Errors Over Time

Is there any good documentation (blog/forum post, etc.) that covers common techniques for handling the build-up of Mecanim root motion errors that cause agents to move off their mark over time?

There is a not uncommon use case where an agent needs to run various animations while staying on a particular mark (position/rotation) for an extended period of time. For example: A background character interacting with something or someone for the entire time the player is in the scene. Humanoid Mecanim can handle this fine if the agent has a single looping animation with zero root motion for the clip. But at soon as any transition between animations is introduced, even if the total delta motion for the clips is zero, small root motion errors will cause the agent to slowly, over minutes, drift off its position and rotation.

I've come up with several hacky solutions. But I'm hoping that someone has documented some good techniques for correcting the slow drift in position and rotation.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by SteveFSP · Nov 28, 2016 at 04:59 PM

It has been a while with no answers to this question, so here is the solution I came up with.

The quick answer: Periodically use Animator.MatchTarget() on Root.

The trick is determining when to trigger the match operation. First, find all points in the sequence where the agent ends on a known position/rotation mark.

Of those, first try out the clips where there is a lot of translation and/or rotation at the end. This can be used to hide any corrections that occur during the match operation. E.g. As part of the sequence, an agent steps forward, does something, then steps back to its mark. The end of the step-back clip may have enough foot motion to hide corrections. You may need to experiment with the match duration to get the best result.

In cases where there is no suitable translation/rotation at the end of any of the clips, the next best option is to select a clip that has a lot of upper body activity. (E.g. The agent waving its hands around in an agitated manner.) The player will tend to focus on the upper body, making it less likely root corrections will be noticed.

After a location for the match operation has been selected, the next choice is how often to trigger the match. Sometimes the length of time between runs of the chosen clip is long enough to justify running a match every time the clip is run. Otherwise you can implement a timer that only allows the a match operation the next time the clip is run once the timer has triggered. Or you can choose something like "run the match every fifth time the clip is run".

There were several instances I've run into where I had to trigger a match operation every time a clip was run. This may have been fixed in more recent versions of Unity, but in some cases a large rotation periodically messed up the agent's rotation in a major way with just one run of the clip. In this case I always ran the match. E.g. I had a sequence of clips that caused the agent to turn around 180 degrees, do something, then turn back. Sometimes, with no detectable pattern, the agent would end the turn 20 to 40 degrees off from its expected rotation. That one required a match operation every time the clip was run, just in case the odd behavior occurred.

Hope this helps.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Teksel · Sep 12, 2019 at 03:29 PM

Hi! Thanks for the detailed answer. Take a look on this forum thread also. The Unity dev explaining the theory behind this - https://forum.unity.com/threads/apply-root-motion-rotating-object-not-accurate.439476/

My Solution to get rid of Root Motion error was: I have added couple extra frames in the beginning and the end of animation clip, so now engine almost never end up in position that the last important frame is cut-off because of the Update/Tick cycle. Worked for my case.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Smooth transition of position between animations 0 Answers

Root position or rotation are controlled by curves error on re activating game object! 1 Answer

how to fix roll animation resets to animation start position 0 Answers

Moving Character to exact position using animation. 0 Answers

Root Animations are inaccurate 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges