- Home /
Is it possible to Duplicate/copy/clone an animation?
Good afternoon, fellow developers!
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?
Answer by GameVortex · Nov 02, 2014 at 09:09 PM
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.
Thank you, GameVortex!! I've tried multiple ways of duplicating the animation clips that have not worked but control+D works perfectly! (Whenever I copy/paste the asset in the project folder I get an empty animation clip [which makes sense as Unity does not suggest copy/pasting assets while in windows]). Oddly enough, I've seen the Ctrl-D method on other assets but have always used my mouse to right clip and copy paste the asset for other types of files in Unity. Thanks again, I'll be using this quite often for the project I'm in!
I use control D but the new animation is not associated with the game object as the original was, which kind of the idea of this =(
that's because the animation must be added to the animator of the game object
Answer by Julien-Lynge · Aug 15, 2016 at 06:03 AM
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.
Answer by ripperdave · Sep 04, 2017 at 05:50 AM
I also missed this function in Unity editor.
Go to the file directory in your drive and copy-paste + rename the animation file. Meta file will be generated by Unity.
Answer by Hoorza · Feb 12, 2018 at 08:58 PM
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.
Your answer
Follow this Question
Related Questions
Little problem with animations 2 Answers
Benefits of root motion 1 Answer
Why does my Mecanim Avatar run in a huge circle 0 Answers
Mecanim animation over network - uLink 0 Answers
Mecanim, using an empty state 1 Answer