Simple index out of range question?

Hello guys I have a very simple problem here:

 var x = Input.touches[0].deltaPosition.x * rotateSpeed * Time.deltaTime;

its a line of a code that orbits around my character, but it throws the error “index out of range”, I figured out that it was because Input.touches[0] can be exceeded but how can I prevent my code from doing that?

something like: if(Input.touchCount > 0){here something}

That’s exactly it, actually. touches[0] doesn’t exist if the player isn’t currently touching the screen. Checking touchCount beforehand will allow you to access the array safely.