Animation 'Use Root Motion' Pushing Z-Axis Back A Certain Amount Each Time Played

Hi All,

Got a problem with an animation of mine. I have a set of draws that use the same animation. I applied the ‘Use Root Motion’ to get it to play at the transformations root location. However, the problem is, I will play the animation, draw opens, press the draw again, the draw closes, but if I keep opening and closing it, the close animations pushes back an extra 0.5 on the Z-Axis each time the animation is played. I can’t find the reason why!

Here’s the code I am using:

    /// <summary>
    /// Woohoo! Shorter code! Instead of using an if after if for each object. In this function,
    /// we will react to each object that has a tag of "AnimatedObject" and we also grab the current
    /// animator attatched to the object we are looking at. We set up a temporary bool that handles the on and off state.
    ///
    /// </summary>
    /// <param name="objectBoolsName"></param>
    /// <param name="objectAnimator"></param>
    void InteractWithAnimatedObject(string objectBoolsName, Animator objectAnimator)
    {
        bool objectBoolValue;

        objectBoolValue = objectAnimator.GetBool(objectBoolsName);

        if(objectAnimator == null)
        {
            Debug.Log("Error: " + objectAnimator.transform.gameObject.name + " is missing an animator component");
        } else
        {
            objectBoolValue = !objectBoolValue;
            objectAnimator.SetBool(objectBoolsName, objectBoolValue);
        }
    }







Just a little update, I noticed that some of the settings in this screenshot are wrong as I was testing out different ways of fixing it. ‘Root Motion’ is ON, and the draw animation close has an animation attached to it

UPDATE: NEVER MIND. FOUND OUT HOW TO FIX IT. SETTING -1 ON THE CLOSE ANIMATION. PLEASE CLOSE/DELETE, WHATEVER NEEDS DOING XD

hi, what did you exactly mean by this? i didn’t really get it.