Hi all,
I'm new to working with Leap motion and have to work with Unity 5.4.1 for a project, where only the core 4.1.5 is the recent compatible version. When I want to interact with an object (pick-up the object), I want to parent the object to a hand (probably the brush hand that is holding the object) and de-parent whenever I release the object.
I'm currently struggling to get a reference to the hand object. I tried to following from an old post: https://community.leapmotion.com/t/orion-get-hand-gameobject-by-hand-id/4873. I currently put a getter in LeapHandController to access the dictionary, after that I don't know what to do with the HandProxy (can't seem to get the HandModel). My current script attached on an empty gameobject:
public class CustomDebugHand : MonoBehaviour {
LeapProvider provider;
public LeapHandController controller;
public HandProxy handProxy;
public List<Leap.Hand> hands = new List<Leap.Hand>();
// Use this for initialization
void Start () {
provider = FindObjectOfType<LeapProvider>() as LeapProvider;
controller = FindObjectOfType<LeapHandController>() as LeapHandController;
}
// Update is called once per frame
void Update () {
Frame frame = provider.CurrentFrame;
hands = frame.Hands;
for (int i = 0; i < hands.Count; i++)
{
Leap.Hand hand = hands[i];
handProxy = (HandProxy)controller.GetGraphicsReps(hands[0].Id);
// ?
}
}
}
If anyone has a better approach or can tell me what which step I have to take. Please let me know, thanks!
Edit: If anyone is wondering how I made the get function that I made in LeapHandController:
public HandRepresentation GetGraphicsReps(int key)
{
HandRepresentation result = null;
if (graphicsReps.ContainsKey(key))
{
result = graphicsReps[key];
}
return result;
}