If you are an animator, you must have been in this position yourself. I have a scene that i animated a long time, but later on made a major change in the rig, and the new rig no longer could work with this animation. Before we go into the details of how I transferred all the animation keys to the new rig, let me tell you the change I did to the rig.
Things we will be discussing in this blog;
1) how to make a character hold an object and still be able to move the hand and object.
2) how to transfer animation keys quickly between 2 objects
3) discussing a few scripts to do the copying of keys for us.
Description of the problem:
Previous Rig :
I had a IK control for the arms. Now, in this particular scene I had to constrain the hand to a few objects. I animated it the bad way by constraining that Ik control to many objects and switching the weights. But I realised soon, I needed a work around as I was no longer able to move the hand or the object
With a little help from my peers and the internet, I decided to add a locator to the hand constraint. How does this help?
We need to understand the way an object is affected by constraints in world space and local space for this.
take an example:
1) create object A
2) create object B
3) constrain A to B.
Result: when B is moved, A follows. We cna key location of B and A will follow automatically.
Drawback?
The object A cannot be moved independent of B. no matter where you move object A in world space, it will always snap back to B
Explanation:
The constraint was created between Obj A and B in the world space. In this case, the world space and object space are the same for both objects. This means, while in world space A follows B, we do not have the ability to move A or B around in their local space.
So, we need to create local space for these 2 objects. We do this by grouping each object in a separate group.
Steps to follow:
1) create object A in world space.
2) CTRL+G will create a group and put this A inside that group. So, now we have GrpA in world space, and the objectA itself is in a local space within the GrpA
3) create object B.
4) out it in a group GrpB.
5) parent constraint GrpA to GrpB
So, now we have the GrpA following GrpB. We would key the location of GrpB which would move the GrpA in world space. But inside these groups, both our objects are free to be keyed and moved/rotated/scaled.
TIP: make sure the pivot points of the object and the grp are the same.
Using this same logic, I added a locator for the Hand IK and constrained the hand Ik to the locator. Then, Added an offset control for the prop inside the master control. now, I parent the Locator to the Master Ctrl of prop. I can now move the Hand Ik and the offsetCtrl of prop to get the desired animation.
That explains our first question for this blog.
Next:
2) how to transfer animation keys quickly between 2 objects
1) We need the two objects to be in the same scene.
2) open the scene that already has the animation.
3) reference in the rig that needs the keys to be copied over.
4) manually select each control from already animated rig, double-click the time line, right-click COPY. Select corresponding control on new rig and double-click timeline and right-click PASTE.
5) do this for every control
3) Discussing a few scripts to do the copying of keys for us.
Step 4 from above can be scripted. Maybe step 5 can be too. But I dint bother doing that. I was OK with selecting all the controls individually.
What the mcvCopyKey_v001.mel Script does:
1) You select 2 objects. First being the object with keys. Second the object that needs these keys pasted onto.
2) Run the script from shelf/by sourcing it.
DONE!!!
the script is super simple to use. It is scripted to do just this and is not very intelligent. If you select the left hand of source and accidentally select the head control of the destination, and run the script, there is a very good chance you will behead your character. This script is Fast and Dirty. So, use it with caution.
Suggestions to improve the script are always welcome. I will implement them later on. and will email you when a new version is available.
Hmm… WordPress does not allow me to upload non media files. So I am not going to be putting up my script files here. But, if you are interested in seeing them, then email me and I can send them to you.
Now in my case, since I had done a major change in the hand rig, even after copying the keys, the hand positions were off. So, A neat trick to get around this problem.
1) select original hand, select new hand control.
2) point constraint and orient constraint with offsets off.
now the new hand follows the old one exactly.
3) select both these controls so you can see the keys of the old hand in the time slider.
4) start hitting S for set key and the > button to go to next keyframe. By doing this we are keying both the old and the new hand. The old one already has the keys and will make no change to it. The new one is getting the exact translate and rotate information, thanks to our constraints and we are keying them.
5) delete the constraints. The keys will still have the values.
6) remove old reference/delete it.
simple. And with the scripts, it makes the task very very easy.