From Input.GetMouse to Input.touch. Multi-touch and raycasts?

Hi Guys. So I’m trying to figure out how to use Input.Touch. Usually I use Input.GetMouseButton(0) and draw a raycast to where ever the person touched on the screen.

Now what I’m trying to do is make it so the player can touch multiple buttons at once. The arrows buttons and any other button the same time. I want it so you can press anything in Box 1 as well anything from the other Box 2s at the same time. I’ve tried looking at similar answers but am quite confused about how to work multi-touch controls.

So I think what I need is to draw separate raycasts from separate finger touches but I’m not really sure. I heard raycasts are quite expensive so this may not be the best option for mobile controls. Any help is appreciated and I’ll attach the relevant code I have so far. The code below is used pretty much on both scripts but with different hit.collider.names.

Thanks in advance for any assistance!

private var ray : Ray;
private var hit : RaycastHit; 

function Update()
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Click1();
}

function Click1(){
        if(Input.GetMouseButton(0)){ 	
        if(Physics.Raycast(ray, hit,100f)){
	if (hit.collider.gameObject.name == "RightArrow"){ 
        //DoSomething
}
}
}
}

Hi, try this:

function Update()
{
	if(Input.touchCount > 0)
	{
		for(var i:int = 0; i<Input.touchCount; i++)
		{
			if(Input.touches*.phase==TouchPhase.Ended)*
  •  	{*
    

_ var ray:Ray = Camera.main.ScreenPointToRay(Input.touches*.position);_
_
var hit:RaycastHit;_
_
if(Physics.Raycast(ray, hit, 100f))_
_
{_
_
Click(hit.collider.gameObject.name);_
_
}_
_
}_
_
}_
_
}_
_
}*_

function Click(name:String)
{
* if(name.Equals(“RightArrow”))*
* {*
* //DoSomething;*
* }*
* else if(name.Equals(“SomethingElse”))*
* {*
* //DoSomethingElse*
* }*
}