Unity: Re-parenting Animations

This article covers Unity’s current animation limitations with regards to hierarchy changes and ways around it. Also discusses modifying Asset files using a text editor. Lastly, mentions an automated tool for my current solution to Unity’s animation limitations.

Unity’s current parent child policy limits animation hierarchy changes.

This means anytime you update an animation’s game-object’s hierarchy, it will break the animations if the change effects it directly. To explain this better, let’s take an example animation with multiple gameobjects.

So, in this example, we have

  • a parent: called “Celebrations“: This has the animator.
  • a child called “BackgroundBox“: Within this child another child called “Text“.
  • an animation called “Wiggle“: The animation rotates “Text” gameobject.

This setup is made for, lets say’s for a Game’s scoreboard screen. The Text Winner wiggles on the screen using the animation when you win the game.

Text gameobject is animated

Now If I add another parent to this hierarchy. Things will start getting interesting…

As soon as I add another parent over the Text gameobject or the BackgroundBox. The animations will loose their references.

Added new parent to BackgroundBox breaking the animation

Now, since the animated gameobject has a new parent, it will not work anymore. 🙁

The easiest solution here is to do the animations again and never touch the hierarchy again.

But such a solution, is extremely limiting to Game development. Yes, this should be avoided by proper game design plans, made ahead of building these animations. But things change during development and we must find a way to make this adaptable and friendly to changes.


A real solution…sort of…

This was an example of a simple animation. Sometimes animations can be highly time consuming to re-make. Sometimes you just want an extra parent to attach some scripts that shouldn’t be effected by the animations. In these and many other cases, this is my current go to solution for now…

You can open your .anim file in notepad and edit the hierarchy path there.

All you need to do is edit the .anim file, using any text editor like notepad. Update all the paths to the new hierarchy path and save the file. And voila… your old animation will start working again with the new hierarchy.

For the above example, this is how it will look.

Here’s how it looks like in Unity now.

Animation properties detecting the new hierarchy.

And my animation is now back to working like it used to!

Re-parented animation is working again.

Important Note for using the above solution…

To edit an asset file in Unity using a text editor. Like the .anim file we just modified, your Unity settings must be set to the correct mode.

Your Unity Editor Settings must be set to Force Text for Asset Serialization mode.

This setting must be Force Text

I see no need to have them set to Force Binary during development, since Unity will convert all Asset files to Binary when making a build.


Having the setting set to text allows you to edit Asset files outside Unity.

Things like updating broken GUIds references. Updating transforms. Animations curve updates. Scene file changes to compare revisions. So many more things you can do!!!!

Lastly, there is also a mixed option for manually managing which asset must be text or binary. Just to give an example here’s what editing the .anim file from the above example would look like, when set to Force Binary.

Editing a .anim file when set to Force Binary in Unity Editor Settings.

I recently found a tool to make these steps automated. Never used it so far though. Here’s the link in-case you are interested.

https://github.com/gydisme/Unity-Game-Framwork/tree/master/Assets/Editor/CustomEditor/Monitor4AnimationCurve


More topics to come…

Same object animation keys get confused.

Never animate parent holding animator.

same animation of mulitple game objects example.

indirect changes to parent doesn’t effect this. Moving parent that has the animator.