• Editor
  • How to make both hands stay on the weapon?

Related Discussions
...

I'm using ik to move my character's arms naturally and it works great. The problem is that i have a 2 handed weapon that i want him to hold with both hands, but i don't know how to make it so that i can move the weapon around freely and have the hands stay on the weapon so the arms move around with it. I was thinking of using IK or Transform Constraints but i only manage to do it for one hand, i made a separate bone for each hand placement on the weapon and i tried to constrain the hand bones to their respective weapon placement bones so that when i moved the IK it would follow normally, i also tried transform constraining the IK's on the arms as well but that doesn't seem to work? I'm sure i'm missing something but i can't figure it out :S help?

Hello MadPropz101! I made a small project to show you how you could do it, basically, make the weapon a child of the root or of a container (with a container it's easier to move the whole skeleton around), then create ik contraints for the hands, but make them follow bones that are parented to the weapon. Finally, to keep the orientation of the hands the same of the weapon, create two transform constraints that mimic the rotation of the weapon.

Erikari wrote

Hello MadPropz101! I made a small project to show you how you could do it, basically, make the weapon a child of the root or of a container (with a container it's easier to move the whole skeleton around), then create ik contraints for the hands, but make them follow bones that are parented to the weapon. Finally, to keep the orientation of the hands the same of the weapon, create two transform constraints that mimic the rotation of the weapon.

Hey thanks for the answer, i tried doing this but the problem is that the hand/arm IK's can't be part of the weapon because when the weapon is not present the character won't animate properly (also there are different types of weapons). Unfortunately it doesn't seem like Spine allows multiple IK's for the same bones?!

Actually it does! Here's the new project, now not following the weapon in setup mode, but following it in the animation.

I've created two additional bones that will stay on the weapon. when the weapon is present, turn on the transform constraints so that the IK targets will follow them.
In setup mode they can be all set to 0 influence, and then set at 100 in animate mode.

Make sure that when you create the transform constraint for the hand ik, you move the ik AFTER the transform constraint in the tree order, or it won't work.


I had auto-key turned off so the animation was actually empty, project updated.

Erikari wrote

Actually it does! Here's the new project, now not following the weapon in setup mode, but following it in the animation.

I've created two additional bones that will stay on the weapon. when the weapon is present, turn on the transform constraints so that the IK targets will follow them.
In setup mode they can be all set to 0 influence, and then set at 100 in animate mode.

Make sure that when you create the transform constraint for the hand ik, you move the ik AFTER the transform constraint in the tree order, or it won't work.


I had auto-key turned off so the animation was actually empty, project updated.

I tried replicating the same thing but the hand ik's don't pull the bones when they follow the transform 🙁 . I'm sending the project as an attachment so i hope you can help me out.

MadPropz101 wrote

I tried replicating the same thing but the hand ik's don't pull the bones when they follow the transform 🙁 . I'm sending the project as an attachment so i hope you can help me out.

Yes, I know this would happen, which is why I wrote:

Erikari wrote

Make sure that when you create the transform constraint for the hand ik, you move the ik AFTER the transform constraint in the tree order, or it won't work.

You can drag elements in the constraint order to reorder them, drag the iks AFTER the transform contraints and they will be working again!
Constraints: Order


This gif is in Japanese but it should get the point across anyway:

(the gif comes from this thread: IKを設定するボーンの親がrootじゃないと動かない時がある )

a month later

I'm implementing this technique of two-handed weapon animations in one of my projects and it's become apparent that it would be useful to be able to have points as the targets of IK constraints. This would let you, for example, easily implement a dagger skin and a spear skin using the same IK constraint. You have skin placeholders fore left and right hands, and a skin for the spear and for the dagger. Each skin has points where the left and right hands of the character model should hold the corresponding weapon.
I realize you can't key point transforms in animations, but I still think this feature would be worth having to simplify things two-handed weapons.
Does this make sense? Am I missing any complications?

It's an interesting idea. The complications are just that a point is an attachment, not a bone, so an IK constraint would have special cases any time its target is considered. The slot cannot be a descendant of the IK bones, just as a target bone can't be, so the editor needs to enforce that invariant.

The IK would probably point at a slot (like a path constraint), not a specific point attachment, and it would use the visible point attachment in that slot (other attachment types would be ignored). I added an issue to keep track of the enhancement:
https://waffle.io/EsotericSoftware/spine/cards/5b6818a5027e37001bc8eef6
Cheers! :beer:

The rotation from the Hand transform constraints does not match the rotation on the weapon causing me issues with my character trying to hold a shotgun with two hands. Any suggestions?

Edit: If I manually rotate the hands I can get what I want but I am not sure how I would allow my character to aim dynamically in game with this set up. Should I set up 8 or 16 aiming poses individually for when my character shoots his gun to give the player the perceived affect of being able to dynamically aim? Sixteen poses would be a lot of firing animations to code into my player script but I believe it can be done, this would only have to be done in code once and then my animations would have to be in line with the coding.

Is it just the angle of the hands that's an issue?
Are your arm bones upperarm, forearm, hand?
Are the IKs that attach the arms to the gun controlling the upperarm and forearm bones?
If so, I think you can get what you want with a transform constraint on both hand bones that targets the gun bone, and with only angle mix turned up. Play with the amount of angle mix and you should be able to make it look good. Don't forget to match the offset when you've manually posed it before you turn up the angle mix.

@tjbrunetto if you download the file I attached to this conversation (on my second message in the thread) you'll see that the hands follow the weapon, which should be a solution to your problem. It follows the system supersaiyansubtlety described in the message above.

I have the two IK targets coming from the bicep to the forearm and then the IK Target is the exact spot where the hand bone starts. I have two gun bones. One gun bone is used to control the movement of all of the gun movements which is working nicely. The other gun bone is to hold the Shotgun Pump for lack of a better word that is on a path constraint that can be moved horizontally to reload the shotgun after firing. The issue is that the hand that goes around the shotgun needs to be in the exact same position as the shotgun or the area of the shotgun that I erased in photoshop shows through. I needed to erase part of the shotgun because my players hand needed to be infront of the shotgun with his fingers but behind the shotgun with his thumb.

So far I have the IK Targets path constrained to two bones on the weapon. I then pathconstrained the hand bones to these two bones on the weapon and turned the rotation all the way up with link sliders turned off. I found that the incosistencies were there enough so that I could not use this rig because my players erased shot gun was showing itself. I have been manually controlling the movements in animation mode and it has been working fine but if I managed to get this to work, my workflow would be much faster.

Also sorry to add more to this but my players shoulders are not moving with the IK constraints either. They stay in place which doesn't look terrible, but definitely doesn't look agile either so I have been moving those manually as well. Again not a major concern as I can manually move them but another slight flaw I found with the workflow.

Tim

Instead of having a hole in the shotgun for the hand, have another image of just the part of the hand that goes in front of the gun and have it drawn on top of the gun.

For the shoulders, I'd try having just the shoulder bone IKed to the corresponding arm IK target and use a low mix.

Hi Supersaiyansubtlety,

I appreciate the help you have offered, I have about 15 more weapons to make work perfectly so I will definitely be trying your suggestions!

Tim

Note you can use more than one IK target and an IK mix < 100% to get varying movement of different body parts. See the spineboy-pro example project: go to animate mode and set the animation to aim, then move the crosshair bone. His rear upper arm (holding the gun) has IK, as expected, but he also has a bone at his hip using IK to point at the crosshair. It's that bone which controls the torso, head, and front arm rotations.

Hi Nate,

I appreciate the help, I have been going through a lot of the spine project examples lately for ideas and hints on how to do things lately. I noticed what your talking about the other day. I will take a look at how it is rigged a little closer in the next few days!