argumentexception: index out of bounds

Hey,

This is probably a really easy question, but i am new in unity and i cant fixed it. I want to only one touch. if people touch it twice. it becomes 2 touches.

UnityException: Index out of bounds.

can somebody help me?

         void Update()
            {
        		Touch touch =Input.GetTouch(0);
        
                if (dead)
                {
                    DCD -= Time.deltaTime;
                    if (DCD <= 0)
                    {
        				if (Input.GetTouch(0).tapCount > 0)
                        {
                            Application.LoadLevel(Application.loadedLevel);
                            VFalse.SetActive(true);
                        }
                    }
                }
                else
                {
        			if (Input.touchCount > 0 && touch.phase == TouchPhase.Began)
        				didFlap = true;
                }
            }

With “Input.GetTouch(0)” you’re assuming that there is already at list one touch in the list. But this is not guaranteed. Before accessing it, you need to check if “Input.touchCount” is > 0.