I have an animation created with the built-in dope sheet. It plays correctly but I would like it to be played relative to current object transformation. For example I have a palm tree that moves its leaves. If I rotate the palmtree and then start the animation leaves does not play animation relative to its new position/orientation. I know it is playing this way because of the animation being absolute. Is there any way to make it realtive to current transformation?.

Thanks in advance.


The only way to do this is to make an empty gameobject and then put the object you wish to animate inside it, then putting an animator on the new parent.

For example, here you would put the tree and leaves in a parent object, and transform the parent object as needed while the animation plays relative to the parent.

  • \$\begingroup\$ Thant worked. Just had to made the palmtree child of a parent and apply the transform in the parent. \$\endgroup\$ – Notbad Apr 9 '14 at 11:19

Another way to handle this, which works well if your objects don't move, is to save the position of the object before you start the animation.

Like so:

        startPosition = transform.localPosition;

Then during LateUpdate, you jus add that position on top of the position of your object, which effectively shifts it by it's original position. Since htis happens in LateUpdate it happens AFTER the animation offset was applied, maintaining the animation.

Like this:

void LateUpdate() {
    transform.localPosition += startPosition;

Since this offset is static this only works with non-moving objects. Of course you could modify this startPosition to move the object but it get's a bit more roundabout then.

Hope this helps :)


You can also :

  • On the animator of the object you want to animate check "Apply root Motion"

  • in the inspector of the animation, click "Generate Root motion Curves"

Et voilà :)

  • 3
    \$\begingroup\$ would you mind to expand a bit your answer a bit more? What is this Apply root motion used for? And what about the root motion curves? I have been reading the doc and I can't get it. Please it would be nice if you could use just plain language. \$\endgroup\$ – Notbad Nov 23 '15 at 0:39
  • \$\begingroup\$ While "Apply Root Motion" will first appears to do the trick, there are cases/instances where you can't use it. The issue that "might" appears" with Apply Root Motion is if your animation is not perfectly reverse looped. (By that, I mean that the animation does the opposite movement after the initial movement). This is because the motion is added to the "root" and so ends up being additive and not relative. This is even more present if you're using a soft transition in the animator setting. \$\endgroup\$ – user3345048 Nov 7 '19 at 0:00

This article explains how to animate objects relative to location. (5 minute read) https://www.highwaynorth.com/blogs/bryan/relative-position-animation-in-unity


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.