LeapMotion模型随手一起移动

1.新建Cube,并创建脚本挂到Cube上;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Leap;
using Leap.Unity;

public class Pickup : MonoBehaviour 
{
    LeapProvider provider;
	// Use this for initialization
	void Start () 
    {
        provider = FindObjectOfType() as LeapProvider;
	}
	
	// Update is called once per frame
	void Update () 
    {
        Frame frame = provider.CurrentFrame;
        foreach (Hand hand in frame.Hands)
        {
            if (hand.IsLeft)
            {
                transform.position = hand.PalmPosition.ToVector3() + hand.PalmNormal.ToVector3() * (transform.localScale.y * .5f + .02f);
            }
        }

	}
}

 

你可能感兴趣的:(LeapMotion)