How can I stop a parented object from resetting its transform when a parent animation play?

Here’s my problem : I’m trying to make an object rotate 90 degree over time (blockController). I made an animation that would do such, placed it on an animation component in an empty object(animatron). Now I figured that by parenting the animatron to the blockController, I could have the animatron rotate it and the blockController, then unparent itself and reset its position.

So far it works. What bugs is afterward, when I try to do the operation again : I assumed that I would just have to parent the blockController under the animatron again and that playing the animation would result in the blockController turning an additional 90 degrees.

What happens is that it follows the coordinate of the animation from start again, meaning it resets its rotation and rotate the original 90 degrees. It’s where my knowledge gets fuzzy and I’m not sure how and why to fix this… I’m quite the beginner so I still feel I might be missing something basic.

Here are the relevant parts of the code:

    //Function to wait for animation to finish
    IEnumerator waitForAnimation(AnimationClip playingAnim)
        yield return new WaitForSeconds(playingAnim.length);
        blockController.transform.parent = null;
        animatron.transform.position = new Vector3(0,0,0);

            //Place animatron over block position
            animatron.transform.position = blockController.transform.position;
            //Parent to block, play anim, unparent after anim is played and reset animatron pos and rot
            blockController.transform.parent = animatron.transform;
            StartCoroutine (waitForAnimation(animatron.animation["rotationCwise"].clip));

It’s repeating the same animation clip because you didn’t record the animation for the additional rotation. That would be a different animation. Animations in Unity start and end at the given angles, positions, scales, etc. that are established when the animation is “recorded.”

However, if my knowledge of unity’s built-in animation is correct, rotations should be local, so you may want to either rotate the object’s parent before the second rotation, or parent a handle game object that can be rotated to the animated object’s original parent, and rotate that, after the first animation, and parent the animated object to this new handle object, for the second animation.

Alternatively, you could simply make a second animation clip and play that clip when you wanted the object to rotate a second time.

Yet another option would be to simply not use the animation system whatsoever, and just apply rotation over time, programmatically.