Sometimes in Touch (UnityException: Index out of bounds) error.

Hello.
I’m sorry dirty in English.

I am referring to the URL below, we have developed an interface like “Fruit NINJA”.
http://answers.unity3d.com/questions/240083/How-to-instantiate-object-at-touch-position.html

There is also a joystick for the operation of character so 2PAD 3rd Person GAME.
(“CameraRelativeControl” in the Standard ASSETS mobile)

I want to like the Fruit NINJA, the only attack the player.

However, repeating the Touch, this error will appear from time to time.
UnityException: Index out of bounds.
Finger_MoveJS.Update () (at Assets/05_Script/Finger_MoveJS.js: 51)

This is part of the script to run on touch the Trail.

Problem can not be resolved, but I tried the various debugging. .
Please tell us how anyone measures to improve

Error occurs in the following locations. ,

"fingerPos = Input.GetTouch (i).position ;" 
or
"if (Input.touchCount > 0 && Input.GetTouch (i).phase == TouchPhase.Ended || Input.GetTouch (i).phase == TouchPhase.Canceled )"

----------------------------------

//@script RequireComponent(Create_TrailJS)

var swipeSpeed : float = 0.1f ;
var inputX : float ;
var inputY : float ;

var TouchZone : GUITexture ;
var touch : Touch ;
var debug_touchPhase : TouchPhase ;
var fingerPos : Vector3 = Vector3(0 , 0 , 50 );
var i : int ;
var inputPlusX : float = 0.0 ;
var inputPlusY : float = 0.0 ;
var FirstTouchPosX : float ;
var FirstTouchPosY : float ;
private var target : GameObject ;

function Start () {

 target = GameObject.FindWithTag("TouchCamera");
 i = target.GetComponent(Create_TrailJS).touchid ;
 FirstTouchPosX = Input.GetTouch(i).position.x;
 FirstTouchPosY = Input.GetTouch(i).position.y;

 Debug.Log ( "First touch posX=" + FirstTouchPosX );        
 Debug.Log ( "First touch posY=" + FirstTouchPosY );        

}


private function GetMovedPosition() : float{
 var MovedAngle = Mathf.Atan2 (inputPlusY , inputPlusX) / (Mathf.PI / 180);
 return (MovedAngle);
}


function Update () {

 if (Input.touchCount > 0)
 fingerPos = Input.GetTouch (i).position ;
 else
 Destroy (gameObject);


 if ( TouchZone.HitTest( fingerPos ))
 {
 if (Input.touchCount > 0 && Input.GetTouch (i).phase == TouchPhase.Ended || Input.GetTouch (i).phase == TouchPhase.Canceled )
 {
         Destroy (gameObject);
         var Dev = GetMovedPosition();
 Debug.Log("MoveAngle = " + Dev + "C");
 }
 
 if (Input.touchCount > 0 && Input.GetTouch (i).phase == TouchPhase.Moved) 
 {
         touchDeltaPosition = Input.GetTouch (i).deltaPosition;
         inputX = touchDeltaPosition.x * swipeSpeed;
         inputY = touchDeltaPosition.y * swipeSpeed;
         transform.Translate (inputX, inputY, 0);
         inputPlusX += touchDeltaPosition.x;
         inputPlusY += touchDeltaPosition.y; 
         Debug.Log ( "X=" + inputPlusX );
         Debug.Log ( "Y=" + inputPlusY );
 }

 else if (Input.touchCount < 0 )
 Destroy (gameObject);
 
 debug_touchPhase = Input.GetTouch (i).phase ;
 } 
    else
    Destroy (gameObject);     
}

The code here looks bogus:

if (Input.touchCount > 0)
   fingerPos = Input.GetTouch (i).position ;
else
   Destroy (gameObject);

You are not checking that i is less than touchCount.

Thank you!
I was thing of the confusion with fingerid "Gettouch " the “i” of …
I was able to be resolved.