View Full Version : Constraining a hand to a sword
I am trying to make a character animation where the character unsheathes his sword from the scabbard, immediately swings it and sheathes the sword back.
The model I am using is generi, which is a free-to-use model by Andrew Silke (http://www.andrewsilke.com/generi_rig/generi_rig.html)
Anyway, I have managed to get it partially working but very dodgily and has one major flaw. I did it by using parent constraint:
The sword is parented to the scabbard
The sword is parent constrained to a locator
That locator is parent constrained to a joint in his hand
The sword's blend parent is keyed at 0 in frame 0
Generi's hand grabs the sword at frame 50 so the sword's blend parent is keyed at from 0 again in frame 49 and keyed 1 at frame 50.
So after frame 50 the sword will always follow the point and orient of the hand.
The flaw with this is when the sword's blend parent changes from 0 to 1 if the Hand is not keyed in the exact right place, the sword "jumps" to where the location of the sword is meant to be in relation to the hand, so the only way around it is if I carefully (and very patiently) place and orient the hand in the exact right place in frame 49 so that in frame 50 the sword doesn't jump to try and match the hand
I know that's probably a little confusing to understand... so I made this GIF animation to help
So do you guys know of any ways around this problem?
Either that or is there another much cleaner way of doing this?
04-04-2010, 05:43 PM
For something like this, these are the steps I usually take.
1. Create a locator, move it to the middle of the sword's handle, and then parent the sword to the locator.
1. Parent constrain the locator to the scabbard in the correct position. The sword will now move with the scabbard.
2. Do all your animation up to the point where the hand needs to take the sword.
3.At the exact frame the hand should take control of the sword, select the hand joint, then the locator, and parent constrain. (This does not create a new constraint, it only adds a constraining target to the existing parent constraint on the locator.)
4. Select the locator, and click on the parent constraint in the channel box, you will see there are 2 attributes W0 and W1 representing the constraining objects. If you leave both values at 1, the sword will always stay halfway between the two targets, because they share equal weight. If you set the weight to 1 on the scabbard and 0 on the hand joint, the sword will only move with the scabbard. If you set the value to 0 on the scabbard and 1 on the hand joint, the sword will only move with the hand.
5. Now that you understand how that works, you need to go to the same frame you made the constraint at, go into the constraint and set the value of the scabbard to 0, and the hand to 1. Highlight both weights, right click and choose "Key Selected".
6. Now go one frame earlier, set the scabbard to 1 and the hand joint to 0. Highlight both channels again, right click and choose "Key Selected"
*The most important part is creating the constraint at the exact point on the timeline where the sword needs to make the switch.
Wow, I had no idea you can key those values in by using key selected.
I've yet to try what you said but thanks very much!
I followed everything you said and it's working great but I'm still getting that jump.
Say the sword needs to follow the hand at frame 40. From frame 39 to frame 40 the sword jumps because the rotation of the sword at frame 39 is not the same as the rotation of the hand so the sword's rotation jumps to match the hand at frame 40
Do i need to just play around with the hand rotation and make sure it matches the sword..?
04-14-2010, 04:55 PM
When you create the parent constraint, make sure you have maintain offset turned on in the parent constraint options.As long as this is on, it shouldn't matter if the hand has different rotation from the sword.
That worked, thanks.
During the parts where hes taking the sword out of the scabbard, it's very difficult to keep the sword inside the scabbard. As in, the sword's mesh keeps going outside of the scabbard and the only way I can see to make sure it doesn't is if I do it frame by frame.
Is there a better way?
04-14-2010, 06:21 PM
A couple suggestions:
1. Use IK with the arm, that way you can translate the hand away from the scabbard at the same angle as the scabbard, which should only take 2 or 3 keys. with FK, you are going to have to pretty much do it frame by frame for the shoulder, elbow and wrist. with IK, you only need to translate the wrist.
2. Not sure what your animation is all about, but doing it really quickly so it only takes a few frames to get it out of the scabbard.
3.Have the blade as a separate object, and just have the length of the blade really short when it is in the scabbard. As he pulls it out, keep animating the blade scaling up so it is just inside the scabbard until it is the proper length.
4. Use a lattice deformer on the blade, and then have the blade pull through the lattice. this method might give you some funky results though.
I am using IK already, the problem is as the hand takes the sword the wrist rotates as well causing the sword to go outside of the scabbard. I guess this is a limitation of the rig, and I will probably need to do it frame by frame.
I can't just do it really quickly as it needs to look natural.
Since I can't get the rotation to stay making the blade shorter wouldnt help either
Not sure what you mean by pulling through the lattice, do you mean using lattice as a way to make the blade shorter and longer?
04-14-2010, 09:41 PM
If you put a lattice on an object, it only affects the object while the object is inside the lattice. so if you move an object through a lattice, the lattice will sort of "squeeze" the mesh if you change the lattice shape.
Another option would be to play to the camera. Hopefully you already have your camera set up, so maybe when he takes the sword out, the side with the scabbard is farthest from the camera, and maybe partly covered by the character.
You were saying that the wrist rotates... I haven't used that rig in a long time, but it shouldn't rotate unless you are pulling the handle beyond the normal length of the arm. The main goal with an IK system is to be able to have ultimate control on the wrist/foot regardless of the shoulder and knee.
If the wrist is still rotating, another option would be to point constrain the sword to the wrist and scabbard, rather than a parent constraint. and then to control the rotation, with an aim constraint, where the sword always aims towards the scabbard. This might help with getting the sword out of the scabbard, but then you are now stuck having to create another object to aim at when the sword is out of the scabbard. To do this, you would have to parent a locator or something to the hand, and move it towards where the tip of the sword should be. This way, you can animate the aim constraint switching from aiming at the scabbard to aiming at a locator positioned above the hand.
All these suggestions are more or less a hack, but a hack will look prettier than a frame-by-frame popping animation.
04-16-2010, 10:31 PM
Will second the suggestion to go with a lattice and play to the camera. This is the sort of techinque that actors have been doing to centuries. There is a reason they did it and still do it. Becuase it works. Unless your in a situtation where you can't. IE game engine won't allow you to, there are other hacks that you could do.
04-16-2010, 10:31 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.