unity index out of bounds code example

Example: index out of bound unity c#

// Hey there! oh... you got a bug. but don't worry! I'm here to help you.

// You have this: 
Touch MyTouch = Input.GetTouch(0);

//You need to change it to this:
if (Input.touchCount > 0)
{
  Touch MyTouch = Input.GetTouch(0);
}

//Why you ask? because when you say Input.GetTouch(0); the programm thinks there
//is a touch but there is not a touch always, thats why you need to say at first
//if (Input.touchCount > 0) 

//Hope I help you, good luck :)