Help with touch

Hey,

I have a really confusing problem.

I am trying to implement the follwing:
There is a marble in the scene. Once the player touches the marble, the marble should start to roll.

I have wrote the code, but nothing happens. So, I have rewrote the code for mouse input, and it works fine there.
I dont know what is the problem with the touch version.

Here is the touch version of the code:

enum BallState
{
	phase1 = 0,
	phase2 = 1
}

var ballState = BallState.phase1;

var playerLayer					: int = 11;
var playerMask					: int = 0;
var marbleTouch					: Touch;

function Start()
{
	playerMask = 1 << playerLayer;
}

function Update()
{
	if (ballState == BallState.phase1)
	{
		if (Input.touches.Length > 0)
		{
			for (var touch : Touch in Input.touches)
			{
				//Look for a marble touch
				var ray : Ray = Camera.main.ScreenPointToRay (touch.position);
				var hit : RaycastHit;
				
				if (Physics.Raycast(ray, hit, Mathf.Infinity, playerMask))
				{
					marbleTouch = touch;
					ballState = BallState.phase2;
					break;
				}			
			}
		}
	}
		
	if (ballState == BallState.phase2)
		rigidbody.AddTorque(50 * Time.deltaTime, 0, 50 * Time.deltaTime);
}

And here is the mouse version, which works fine:

enum BallState
{
	phase1 = 0,
	phase2 = 1
}

var ballState = BallState.phase1;

var playerLayer					: int = 11;
var playerMask					: int = 0;

function Start()
{
	playerMask = 1 << playerLayer;
}

function Update()
{
	if (ballState == BallState.phase1)
	{
		if(Input.GetMouseButton(0))
		{
			//Look for a marble touch
			var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
			var hit : RaycastHit;
				
			if (Physics.Raycast(ray, hit, Mathf.Infinity, playerMask))
			{
				ballState = BallState.phase2;
			}			
		}
	}
		
	if (ballState == BallState.phase2)
		rigidbody.AddTorque(50 * Time.deltaTime, 0, 50 * Time.deltaTime);
}

I have really no idea what is wrong, why the touch version is not working.
I would really appreciate any help.

Thanks!

I think (not 100%) but Input.touches should be, Input.GetTouch(0)

Still not working.
I dont get it, it should works, but it isn’t.
If someone has an idea, please help.

I do a similar thing (without the moving marble) in my game.

Here’s what I do:

function CheckRayCastHit(){
     if (Input.touchCount--1){
          var pRay = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
          var pRaycastHit : RaycastHit;
          
          if (pRaycastHit.transform.gameObject.tag == "Shape"){
               // Do stuff here
          }

          return pRaycastHit.transform.gameObject.tag;
     }

     return null;
}

}

Thanks!