Working with animations in Unity has some quirks. Sometimes I will make an animation and I animated the wrong object. I might have realized I want to animate the container for an object, or accidentally animated the parent when I wanted to animate the child (this happens more often than I’d like to admit!).

Unity does not come out of the box with functionality to remap animations between objects. But there are a few options to make your life easier. I’ll go over 3 ways to fix this: the Animation Hierarchy Editor, my Search & Replace tool, and manually editing the YAML.

Animation Paths – What are they?

All three methods share the same thing: I want to re-map the ‘path’ of the animation clip’s property to the correct path. What do paths look like? They are simply strings that map the path from the animation root to the animated object. Game objects names are separated by a slash (/) character. Some examples:

MyObject

Parent/Child

GrandParent/Parent/Child

So all techniques shown below are simply changing the clip’s ‘path’ value to a new value.

Animation Hierarchy Editor

Alexander Yoshi has created the useful Animation Hierarchy Editor utility. This allows you to remap between objects quite easily, although the interface is somewhat non-intuitive.

The utility is one .cs file that you can place in the Assets/Editor folder. After installing it choose Window->Animation Hierarchy Editor and dock the window.

Basic Usage

Click on the animation in the Project tab.

Animations in Unity are comprised of Animators with one or more AnimationClips. The animator Parent uses the clip CubeAnimate.

In your scene, or on a prefab, locate the game object that contains the Animator.

The ‘Parent’ object contains an animator that uses the CubeAnimate animation that we want to remap.

Drag this object into the ‘Referenced Animator’ field in the Hierarchy Window.

The window will now populate with the objects used:

The path ‘Cube2’ doesn’t have a corresponding game object, denoted in red. It doesn’t point to any specific object. I can update the path by dragging the MegaCube game object into the red field, fixing the clip:

Switching over to the Animation window shows that the object’s path has been remapped correctly:

Project Search & Replace

My Project Search & Replace tool has the ability to fix animation clips:

Editing The Animation Clip Directly

The Animation Clip exists as a file on your hard drive, similar to a prefab, material, or other Unity object. If your ‘Asset Serialization’ is set to ‘Force Text’ then this file is a text file that you can open in a text editor and modify by hand. Naturally, modifying the file by hand is prone to error, and so it should only be attempted if you feel comfortable doing so.

To locate the Asset Serialization setting, go to Project Settings->Editor. This is under the Edit menu on Mac, but may be somewhere else on Windows (lmk and I can update this!).

Before modifying the clips, make sure that any changes are correctly saved to disk by choosing File->Save Project. Open the file in your text editor of choice (shoutout to Sublime). You’ll see the following data:

See that last line with ‘path’ in it? That’s the path :). Searching & Replacing the value after the colon to another value will update the animation clip to point to a new path. After the file is saved and Unity refreshes the Animation Clip will display the new values.