NullReferenceException with Leap motion

24 Views Asked by At

I'm working on a project with Unity and I've to check if there are any hands in the scene before the Update function. I've written this short code

Hand hand;
HandModel handModel;
private static LeapProvider s_provider;

void Start()
{
    handModel = GetComponent<HandModel>();
    hand = handModel.GetLeapHand();
    if (hand == null) Debug.LogError("No leap_hand founded");
    s_provider = Object.FindObjectOfType<LeapServiceProvider>();
    if (s_provider == null) {
        s_provider = Object.FindObjectOfType<LeapProvider>();
        if (s_provider == null) {
            return;
        }
    }
}

but an error occurs when I press the Play button, refered to hand = handModel.GetLeapHand();: NullReferenceException: Object reference not set to an instance of an object. I know it's a noob problem but I can't get a solution

0

There are 0 best solutions below