Paul Kevin Paul Kevin - 1 year ago 60
C# Question

Cannot implicitly convert type `System.Collections.Generic.List<Leap.Hand>` to `Leap.Hand`

I've got this error
Cannot implicitly convert type


Here's my code:

using UnityEngine;
using System.Collections;
using Leap;
using Leap.Unity;

public class Swimming : MonoBehaviour {

Controller controller;

void Start(){
controller = new Controller ();

void Update(){

Frame frame = controller.Frame (); // controller is a Controller object
Hand hand = frame.Hands;

for (int i = 0; i < frame.Hands.Count; i++) {
if (frame.Hands [i].IsLeft) {
Debug.Log ("Left Hand Detected");

I've searched a lot but i couldn't find something. Can anyone help me please

Answer Source

Your problem is here:

Hand hand = frame.Hands;

frame.Hands is a collection of Hand, but you're trying to assign this value to a single instance of Hand. So, instead, you should be doing this:

List<Hand> hands = frame.Hands;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download