Okay!
Figured out how this is done. Turns out I forgot to export the 3D models for the prefabs in my project. For everyone else, I'll briefly explain what I did (I assume you've download the orion update + HandModules, get from here: https://developer.leapmotion.com/unity#100).
- Drag your Leap rig controller into your scene (in my case it's LMHeadMountedRig).
- You then want to drag your hand models (that should be already rigged) and drop as a child object under the HandModels within your Leap rig controller within the hierarchy
- Expand your Leap rig controller so that you can see the LeapHandController gameobject (it should be the object that has the Hand Pool script).
Hands work as groups. A group is basically a container which has a name, 2 models of your hands (one for left hand and the other for your right hand), a property to say if that group is enabled, and a property regarding duplication (not 100% what this actually does, has something to do with a hand model is not present when the game loads). By default there should be 2 groups already made, although one of the group will have hand prefabs which doesn't have a 3d model for some reason.
4.You want to increase the size of the Model pool (or replace one of the current groups within the pool).
5. Give your group a name, and then drag and drop the 3d hand models from the hiearchy into the Left/Right model properties. BE SURE that you put the hands the right way round.
6. Unchek the IsEnabled property (or keep it checked and uncheck the other groups if you want to load your hand model by default).
Now to get the switching between hand models to work. It is actually simple, not sure why I didn't notice earlier. There are two functions in the HandsPool script that handles enabling and disabling hand models; both functions are public scope, and require a group name string (remember group name from HandPool earlier?) to be passed. You will have to call these functions to switch between hand models. A quick way to switch between hands models:
- Write a new C# script
-
Copy and pasta the following:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Leap.Unity;
public class ChangeHands : MonoBehaviour {
HandPool obj;
// Use this for initialization
void Start () {
obj = this.GetComponent<HandPool>();
}
void Update(){
if (Input.GetKeyDown(KeyCode.A)){
obj.EnableGroup("RigidHands");
obj.DisableGroup("HumanHands");
}
else if (Input.GetKeyDown(KeyCode.S)){
obj.EnableGroup("HumanHands");
obj.DisableGroup("RigidHands");
}
}
}
Drag and drop this script onto the LeapHandController gamobject (the object that has the HandPool script)
Now you can switch if you press A or S, your hand model will switch between the two hand groups. What's happened is as we push a button down, we are disabling one hand group and enabling another. Note that the above is using 2 hand groups, obviously adjust your code to suit your needs. I managed to get it working so that if you pressed a Unity UI button, the hands will change. Here's a (poorly) edidted screenshot that should (hopefully) explain the process. You'll still need to code the hand changing.
Hope this helps, apologies for any grammatical/spelling mistakes (in a rush typing this).