I am a fairly new user to Unity, as part of my studies. Currently, in the scene I have a stick that I want to move using my hands being tracked by the leap motion device. I found a script online to help me do this, which I basically link to the Hand Controller Prefab that comes with Leap motion integration files for unity and attached this to the stick. The stick does move at the moment but the orientation seems to be off (horizontal and vertical have switched). e.g. if my hand is at a vertical angle the stick is horizontal. Also the movement does not seem to be stead. I couldn’t find any other answers that could give me an idea as to why it isn’t working, as about a month ago the orientation was perfect. When I came back to it, I changed nothing but it wasn’t working. I’m trying to get this all to work so you can see it in the Oculus Rift, which the HMD view is working just fine, the leap motion is being temperamental.
Wondering if anyone has any suggestions to how to fix it or a different way to get my hand movements to be linked to a game object so the stick moves as if it is my hand? Hopefully this makes sense.
The script I’m using is shown below:
using UnityEngine;
using System.Collections;
using Leap;
public class MatchHand : MonoBehaviour
{
//Assume a reference to the scene HandController object
public HandController handCtrl;
void Update()
{
Frame frame = handCtrl.GetFrame();
Hand hand = frame.Hands.Frontmost;
if (hand.IsValid)
{
transform.position =
handCtrl.transform.TransformPoint(hand.PalmPosition.ToUnityScaled());
transform.rotation =
handCtrl.transform.rotation * hand.Basis.Rotation(false);
}
}
}