Daily Progress: Making the player models hands stick to the gun.
Most games will have various guns, so to make things easy, we’ll have the guns drive the players hand animations. Inside of the gun object, we’ll add two empties, HandPosition.R and HandPosition.L:
To make things easier, I’m going to add some colorful points to the empties so I can see where they are.
Next, I’ll position the left empty at the gun handle and the right empty at the base of the gun.
Next, we’ll write a simple script to place the hands on the guns via the ik controller. Create a script called SmoothDamp and place it on each IK hand position empty.
Here’s the script for SmoothDamp (credit goes to Al Heck for the script):
Select each IK hand position and drag the proper gun/hand target into the target slot.
If all goes well, our players hands will now stick to the gun!
Oooh…yikes…that’s close but looks painful! Well, just like yesterday, we’ll modify each hand position while in play mode, copy the component data, get out of play mode, and then paste the component data back. If we do it for both hands, we should have a better looking grip.
Pro-Tip: If the arms aren’t appearing while you edit, you’ll want to select both arms, and under skinned mesh render, tick the ‘Update while Offscreen’ box.
Great! I think that’ll work!