Search Unity

Argument Out Of Range Exception error

Discussion in 'Scripting' started by mayank_chaurasia, Jan 21, 2018.

  1. mayank_chaurasia

    mayank_chaurasia

    Joined:
    Nov 10, 2016
    Posts:
    4
    Hi I m new to unity C# coding i had taken help of Leap Motion tutorial to move the camera in and out according to the hand gesture but it is giving me
    ArgumentOutOfRangeException : Argument is out of range.
    Parameter name: index

    code is below

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

    public class ControlMove : MonoBehaviour {

    Controller controller;
    float HandPalmPitch;
    float HandPalmYam;
    float HandPalmRoll;
    float HandWristRot;

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
    controller = new Controller ();
    Frame frame = controller.Frame ();
    List<Hand> hands = frame.Hands;
    if (frame.Hands.Count > 0) {
    Hand fristhand = hands [0];
    }

    HandPalmPitch = hands [0].PalmNormal.Pitch;
    HandPalmRoll = hands [0].PalmNormal.Roll;
    HandPalmYam = hands [0].PalmNormal.Yaw;

    HandWristRot = hands [0].WristPosition.Pitch;

    Debug.Log ("Pitch :" + HandPalmPitch);
    Debug.Log ("Roll :" + HandPalmRoll);
    Debug.Log ("Yam :" + HandPalmYam);

    //Move Object
    //if (HandPalmYam > -2f && HandPalmYam < 3.5f) {
    // transform.Translate (new Vector3 (0, 0, 1 * Time.deltaTime));
    //} else if (HandPalmYam < -2.2f) {
    // transform.Translate (new Vector3 (0, 0, -1 * Time.deltaTime));
    //}
    }
    }
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035