Ideal touch scripting for my rhythm action game

Hi!

I’m trying to make simple rhythm action game with Unity iOS!

It’s bit special tho…

First of all, I’ve made “paths” with box colliders for which they are connected to each other,

and the main camera views them from the top and moves front, which makes it forced vertical-scroller game.

if a player places his finger on the “paths” player gains point per frame,

and if a player’s finger is off from the “paths” player does not gain point anymore.

Theses “paths” cannot only be straight, but it can also be curved or twisted later on.
(Yes, these paths will be curved and twisted depends on the rhythm of the game we are playing)

The main objective of this game is to place my finger as long as possible to earn more points.

var hitFx: ParticleEmitter;
var score: float;
var scoreGUI: GUIText;

function Start()
{
	hitFx.emit = false;
}
function Update () {
	 //var fwd = transform.TransformDirection (Vector3.forward);
		
	var ray = Camera.main.ScreenPointToRay (Input.mousePosition); // Construct a ray from the current mouse coordinates
	var hit : RaycastHit;
	    
        if (Physics.Raycast (ray, hit))
		 {
			//Debug.DrawLine (Camera.main.transform.position, hit.point, Color.red);
			//Debug.Log(hit.point);
			score ++;
			hitFx.transform.position = hit.point;
			hitFx.transform.position.y = -48;
			hitFx.emit = true;
			scoreGUI.text = score.ToString();
			//Instantiate (particle, hit.point, transform.rotation); // Create a particle if hit
		} 
	
}

When I tested it on Unity Editor, it works quite well, but when I tried it in actual device, the touch doesn’t get recognized well. Especially when I made the first touch, or when I perform some curving moves or twisting moves with my thumb, the particle effect doesn’t get generated well.

I do see that the “paths” made with box collider is bit narrow, which may have limited the touch and raycasting thingy,

but I believe widening the “paths” is not the best solution.

This is why I posted this thread to ask you guys for better ideas.

Currently, I’m only shooting a single ray on the Input.mousePosition, which would be a touch position when tested on the device - is it possible to shoot multiple rays for more flexible judgement?

Thanks in advance.

//VARIABLE DECLARATIONS

var hitFx: ParticleEmitter;
var score: float;
var scoreGUI: GUIText;
var hit : RaycastHit;

//INITIATE
Awake(){
hitFx.emit = false;
}

//START GAME LOOP
function Update(){

for (var touch : Touch in Input.touches) {//IPHONE CONTROL SCHEME
if ((touch.phase == TouchPhase.Stationary){

//CREATE RAYCAST FROM CAMERA
var ray = Camera.main.ScreenPointToRay (touch.position);

if (Physics.Raycast (ray, hit, 100)) //SEND RAY TO LINE
{

//Debug.DrawLine (Camera.main.transform.position, hit.point, Color.red);
//Debug.Log(hit.point);
score ++;
hitFx.transform.position = hit.point;
hitFx.transform.position.y = -48;
hitFx.emit = true;
scoreGUI.text = score.ToString();
//Instantiate (particle, hit.point, transform.rotation); // Create a particle if hit

}//END HIT

}//END MOUSE DOWN

}//END IPHONE INPUT

}//END UPDATE

If you think the ray is casting out to too small of an object just increase the collider size for your line. This code should give you more consistent feedback on the device though.