I've been trying to make the leap motion hand to work as a grasping metaphor called "Go-go Interaction"
At a specific distance where the hand is unable to reach the object, I want the leap motion hand to move at a speed.
when all the fingers are extended (open), the hand will move forward according to the speed set. and the hand will stop when all the fingers are not extended (closed). its something like locomotion in leap motion.
the code below doesnt works, can someone please help. thank you
public class MoveHandToCube : MonoBehaviour
// Adjust the speed for the application.
public float speed = 1.0f;
// The target (cube) position.
private Transform target;
startPosition = transform.position;
target = GameObject.FindWithTag("Collect").transform;
//Get Hand objects from a Frame object.
controller = new Controller();
Frame frame = controller.Frame(); // Frame: a set of fingers and hand tracking data. Access through the controller class
List<Hand> hands = frame.Hands;
if (frame.Hands.Count > 0) //obtain valid Hand object from a Frame object
Hand firstHand = hands;
Vector palmPosition = hands.PalmPosition;
transform.LookAt(target); //Target: Cube
float step = speed * Time.deltaTime;
transform.position = Vector3.MoveTowards(this.transform.position, target.position, step);
// Check if the position of target and this approximately equal.
if (Vector3.Distance(transform.position, target.position) < 0.001f)
transform.position = startPosition;