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:
- Create new project.
- Create empty GameObject and a 3D Sphere child object to it.
- Add Animator component to the Sphere
- Sphere selected, create new Animation (this also creates Animator Controller)
- Create sinusoidal loop animation (called “Oscillation”)
- Create Animator bool variable, say, “oscillate”
- 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)
- Check “Apply Root Motion” in Sphere Animator component, create Root Motion Curves for the animation from the Inspector view of the animation
Setup
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
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?)?