UnityEngine.Input.GetTouch (System.Int32 index) : <p>This is ment to be an angry birds like slingshot, i need to detect the begining and end of a touch, the script works but when i lift my finger off the screen The error shows up is about line 24 (I put dots next to it). The error only appears if I dont touch the screen, if i touch it it goes away, it comes back when i lift my finger.</p>

<pre><code>public class BallShooting : MonoBehaviour
{
    public Rigidbody2D rb;
    private bool isPressed = false;
    public bool isDead = false;
    public bool hasShoot = false;
    public int Damage;
    public int BaseDamage = 1;

    public BoxCollider2D DeathZone;
    public Transform startingSpot;

    public GameObject platform;

    public float releaseTime = .15f;
    void FixedUpdate()
    {

        if (Input.touchCount &gt;= 0 &amp;&amp; isDead == false)
        {
    ...        if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
               // Debug.Log("TouchBegan");
                isPressed = true;
                rb.isKinematic = true;
            }
            if (Input.GetTouch(0).phase == TouchPhase.Ended)
            {
              //  Debug.Log("TouchEnded");
                isPressed = false;
                rb.isKinematic = false;

                StartCoroutine(Release());
            }
        }

        if(isPressed &amp;&amp; !hasShoot)
        {
            Touch touch = Input.GetTouch(0);
            Vector3 touchPosition = Camera.main.ScreenToWorldPoint(touch.position);
            rb.position = touchPosition;
        }


        if (isDead)
        {
            this.transform.position = new Vector3(startingSpot.position.x, startingSpot.position.y, startingSpot.position.z);
            isDead = false;
            DeathZone.enabled = true;
        }
    }

    void OnTriggerEnter2D(Collider2D other)
    {
        if(other.tag == "Ground" &amp;&amp; hasShoot == true)
        {
            isDead = true;
            Debug.Log("Dead");
            DeathZone.enabled = false;
        }
    } 
    IEnumerator Release()
    {
        yield return new WaitForSeconds(releaseTime);
        GetComponent&lt;SpringJoint2D&gt;().enabled = false;
        hasShoot = true;
    }    
}
</code></pre>
