Well, you could write your own scripts to control the bones in your model or you could try to use our scripts (from the Leap Motion Unity Assets).
I've been working on a tutorial for using rigged model hands with our scripts. It isn't perfect or complete -- I still got inconsistent results, but I'm posting the basic steps below in case it helps. There is also a list of relevant posts about rigged hands on this forum here: https://community.leapmotion.com/t/using-custom-hand-rigs/4438
Rigged Hand Tutorial (Incomplete)
First of all, the most difficult part of the problem is getting the skinned mesh hands to align with the colliders in the physics hands. I think this is only possible if the bones in your rig are the same length and have the same rest orientation as the bones in our internal hand model. These values can be derived from some code I posted here: https://community.leapmotion.com/t/issues-with-rigged-hand-fingers-in-unity-5/4227/2 (if that isn’t clear enough, I’m happy to provide the numbers directly).
A second approach to handling the alignment of the rigged mesh to the colliders and physics objects, is to combine both into one Unity object. If you aren’t doing physical interactions, this is probably the easiest way — just put Collider objects on the bone transforms and don’t use the physics hand prefabs at all. If you are doing physical interactions using Unity’s physics engine, then things are more complicated. I won’t go into it here, but if you are interested in this approach let me know and I can tell you what I’ve figured out so far.
Once you have a rigged mesh, the steps for creating a Unity object that can be used with the HandController are:
- Import model Set scale — roughly the same size as the existing
models
- Drag model to hierarchy
- Add RiggedHandScript
- Add Empty object, rename to Hand
- Add an Empty object to Hand, name it Offset
- Add Empty object to Offset, rename to Arm
- Drag root arm bone to Arm
- Drag root hand bone to Offset
- Assign Hand to the RiggedHand script palm transform
- Assign Arm to the RiggedHandScript forearm transform.
- Adjust the Offset translation to put the palm position of the mesh
at 0,0,0 (It is helpful to place a small 3D primitive at the origin
as a marker)
- Set Model Finger Pointing and Model Palm Facing in
RiggedHand Script based on the rest pose of the hand. These are
direction vectors and are easy to set if the hand is aligned with
the axes.
- Next, add a HandController object to the scene and position it so that you can see the hands in the Game view.
- Assign your under-construction RiggedHand object to the HandController
graphics model (for left or right accordingly).
Test your hand. See if the hand is oriented correctly and the wrist joint looks and rotates correctly
Common errors include:
- Not making Arm a child of Hand
- Using the wrong bone for the palm
- Not setting finger pointing and palm face directions properly
Switch to Scene view and select the HandController in the Hierarchy. Compare your hand to the rigid bodies. They should line up with the palm and arm.
Common mistakes include:
- Wrong scale — set the scale of the model in inspector (probably have to start over after doing this)
- Wrong offset — Adjust the Offset translation
Now do the fingers:
1. Add The RiggedFinger script to one of the top level finger bones.
2. Set the Model finger pointing and palm facing values to the same used for RiggedHand
3. Copy this RiggedFinger component and paste it to the four other top level finger bones.
4. For each finger, drag the bone transforms to the corresponding position in the RiggedFinger bone array.
- Item3 should be the distal bone(not the tip)
- Item2 should be the intermediate phalange
- Item1 should be the proximal phalange
- Item0 should be the metacarpal, but isn’t articulated in the LM hand model, so it isn’t necessary if your rig doesn’t need them. The LM hands don’t use this slot.
Finally, Drag the bones with the RiggedFinger script components to the corresponding slots in the Fingers array of the RiggedHand script.
Test