I continue to get an index out of bounds error in my console. I don’t know what’s causing this. It is specifically this line - if(Input.GetTouch (0).deltaPosition .x<0). I tried adding if(Input.GetTouch (0).deltaPosition .x<0 && Input.GetTouch>0) in both if functions, but this did not work.

Here’s my code (located in the Update Function):

if(!PausePanel.isPaused && mySpriteRenderer != null)
	{
		if(Input.GetTouch (0).deltaPosition .x<0)
		{
			// flip the sprite
			mySpriteRenderer.flipX = true;
		}

		if (Input.GetTouch (0).deltaPosition.x > 0) {
			// flip the sprite
			mySpriteRenderer.flipX = false;
		} 

}

It’s because there are no touches currently, so Input.GetTouch(0) is trying to get the touch in the first index of an empty array. You’re going to want to check the touch count:

if(!PausePanel.isPaused && mySpriteRenderer != null && Input.touchCount > 0)
     {
         if(Input.GetTouch (0).deltaPosition .x<0)
         {
             // flip the sprite
             mySpriteRenderer.flipX = true;
         }
         if (Input.GetTouch (0).deltaPosition.x > 0) {
             // flip the sprite
             mySpriteRenderer.flipX = false;
         } 
 }

try to edit
if(Input.GetTouch (0).deltaPosition .x<0 && Input.GetTouch>0)

to

if(Input.touchCount >0 && Input.GetTouch (0).deltaPosition .x<0)

you need checking touch count before check input.GetTouch(0). and you wrong “Input.GetTouch