Hi there,
I'm trying to convert my old Unity projects that were using the 2.3.1 version of the SDK to the newest Orion SDK. I've been reading lots of threads regarding the new arrangement of LeapProvider, Controller etc.
To put it simply, I'm trying to create a very simple test scene, where the x rotation of a rectangle is dictated by the pitch of the hand.
This is the code I have been led to believe would work:
public LeapServiceProvider leapProv;
public Hand thisHand;
public Frame frame;
void Start()
{
leapProv = GetComponent<LeapServiceProvider>();
}
void Update()
{
frame = leapProv.CurrentFrame;
if (frame != null && frame.Hands.Count > 0)
{
thisHand = frame.Hands[0];
if (thisHand != null)
{
float pitch = thisHand.Direction.Pitch * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(new Vector3(pitch, 0, 0));
}
}
}
This results in my object spinning rapidly, faster as the pitch value gets further away from 0.
However, upon fiddling about, I have found that this code works exactly how I intend it to:
public Controller controller;
public Hand thisHand;
public Frame frame;
void Start()
{
controller = new Controller();
}
void Update()
{
frame = controller.Frame();
if (frame != null && frame.Hands.Count > 0)
{
thisHand = frame.Hands[0];
if (thisHand != null)
{
float pitch = thisHand.Direction.Pitch * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(new Vector3(pitch, 0, 0));
}
}
}
It seems that getting the frame from a Controller results in accurate movement of the rectangle, yet getting the frame in the new way from the Provider doesn't.
I assume I am missing something - can someone help?
Here is a screenshot of Unity with the components that are attached to my cube object: