Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed Mar 28, 2016 at 12:26 PM by juliuslaak for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by juliuslaak · Mar 22, 2016 at 07:25 AM · animationanimatorlooproot motion

How to get perfect position animation with root motion?

I have a problem with a 3D sphere animation. Given a simple sinusoidal transformation in, say, x-position, one loop cycle ends always in the coordinate of origin. However, when using Root Motion, the loop ends always a little bit shifted from the origin.

Here is how to replicate the problem:

  1. Create new project.

  2. Create empty GameObject and a 3D Sphere child object to it.

  3. Add Animator component to the Sphere

  4. Sphere selected, create new Animation (this also creates Animator Controller)

  5. Create sinusoidal loop animation (called "Oscillation")

  6. Create Animator bool variable, say, "oscillate"

  7. Create new Idle state (mark as default) and create transformation to "Oscillate" animation, add conditional transformation using the "oscillate" variable (true->transform to "Oscillate", vice versa)

  8. Check "Apply Root Motion" in Sphere Animator component, create Root Motion Curves for the animation from the Inspector view of the animation

Setup alt text

9.Lock the Sphere object inspector view, Play the scene and toggle the bool variable "oscillate" in the Animator view. Every time one loop round ends, the sphere is in another position.

Observed slight shift of the object alt text

This behavior does not occur when Root Motion is not checked in the Animator component. The direct consequence of this behavior is that when switching between Idle and Oscillating several times, the Sphere moves from the position (0, 0, 0) to, say, (0.87, 0, 0).

What is going on and how to avoid this behavior? Is it a bug or is it completely normal (if yes, then, why?)?

root-motion.png (13.0 kB)
unity-ball-screen-1.png (208.7 kB)
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

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by juliuslaak · Mar 28, 2016 at 12:26 PM

I solved this problem bruteforce by attaching the animation state a script with the following functions:

 private Transform transform;
 private Vector3 transformPosition;

 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
         transform = animator.GetComponent<Transform>();
         transformPosition = transform.position;
     }

 override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
         transform.position = transformPosition;
     }
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

Follow this Question

Answers Answers and Comments

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

Player teleports when animation finishes 0 Answers

Root motion on animation clips created at runtime 0 Answers

Root Motion not having gravity (while Animate Physics turned on). 1 Answer

It is possible to create AnimationClip ingame whose do not loop / reset position? 0 Answers

How To preserve Forward momentum of an anim throughout another anim? 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