I’ve been doing quite a bit of animation work in Mecanim over the past few weeks and I’ve noticed when searching that there doesn’t appear to be a way to copy or duplicate an animation clip. I’m trying to copy an animation because I have quite a few animations in my project that work great for the objects they are attached to but I have a few objects that need an animation that is identical to one I’ve already made except it needs to be tweaked by say 5-10%. Due to the time that went into making the original animation clips, it would be quite time consuming if I couldn’t make a duplicate of the animation clip and just tweak it to suit the other objects. Is this possible?
For example, I’m making a 2d project so maybe a few sprites need to be changed in the animation clip of 16 sprites plus perhaps I want a child object to do something in the animation at a set time that for object A makes sense but would not apply to object B.
To compare to other practices, when I approach making a script that uses recycled code I grab the previously typed code and tweak it in the new script. When I’m doing art, I grab a previous image I’ve made and tweak the arm over several layers to make a wave animation. When it comes to Unity and the animation clips, can they be duplicated so that tweaking a set animation can be done and saved without changing the original animation clip?
As @MorphVGX mentioned, @GameVortex’s answer is correct insofar as it tells you how to copy an asset in Unity. However, it doesn’t explain how animations work and what you have to do to be able to edit the copied animation. This was something I’ve previously gotten stuck with - it seems so obvious and then doesn’t work - so I wanted to provide more detail about animations in particular.
If you want to copy an animation, you start with ctrl-D / cmd-D as with all other assets. Then, if you want to associate it with a particular game object and its children for editing, you have to add it to an AnimatorController. (You don’t have to do anything with it in the AC - it just has to be linked to a state - so you can just drag it into the AC to have it automatically create a state for you). Once it’s referenced by the AC, you will need to make sure that that your GameObject in the scene has an Animator component, and that it’s referencing your animator controller.
One you have all that set up, if you select the GameObject and open the Animation window, you’ll see your animation clip in the list. This list is populated based on the states in the AnimatorController.
An animation clip is a file just like all other types of assets in you project. To duplicate it you can select it in the project view and click ctrl-d, or open the project folder, navigate to the file and copy paste it normally. If the clip is part of an imported model ( which I doubt, because then you would not be able to modify it in unity at all) then you will have to duplicate the model file instead.
In the Timeline, you can copy animation that has been turned into the clip most easily. Simply duplicate the object and place it on the new animation track. Then duplicate the animation clip in the timeline and move it to the animation track of a duplicated game object. Its position on the timeline can be changed with a simple drag, works like a charm. I have not tested if you can do it if objects that are slightly different but it works for the duplicates. With the “Apply Root Motion” option selected you can move/rotate the game object and animation will not be broken. Hope it helps.