why is Input.GetTouch(0).phase == TouchPhase.Began returning exception?

I’m developing targeting windows phone and I can’t figure out why doing this is throwing an error:

_isHoldingTouch = Input.GetTouch(0).phase == TouchPhase.Began;

_isHoldingTouch is just a bool var.

the error is thrown as soon as I run the game

“WinRTBridge.winmd but was not handled in user code”
{“Index out of bounds.”}

thanks

As the comment suggests, you need something like

if(Input.touchCount > 0)
{
      _isHoldingTouch = Input.GetTouch(0).phase == TouchPhase.Began;
}

Otherwise when there are no Touches you are telling it to get a Touch that doesn’t exist.