LeapMotion模型随手一起移动

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Exclaiming/article/details/81092554

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<LeapProvider>() 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);
            }
        }

	}
}

猜你喜欢

转载自blog.csdn.net/Exclaiming/article/details/81092554