Help with c# code - Multitouch

hello everyone i have this code working :

using UnityEngine;
using System.Collections;

public class DragObject : MonoBehaviour {

	public GameObject Finger1;

	void Update(){

		foreach (Touch touch in Input.touches) {


			if (touch.phase == TouchPhase.Began){

				var ray = Camera.main.ScreenPointToRay(Input.touches [0].position);
				var hit = Physics2D.GetRayIntersection(ray);
				if (hit.collider.tag == "fingers") {
					Debug.Log("selezionato :  " + hit.collider);
					Finger1 = hit.collider.gameObject;
				}
			}
			else if (touch.phase == TouchPhase.Moved && Finger1) {	

				var ray = Camera.main.ScreenPointToRay(Input.touches [0].position);
				var hit = Physics2D.GetRayIntersection(ray);

				Debug.Log(hit.point);
				
				Finger1.transform.position = new Vector3(hit.point.x, hit.point.y, 1);

			}
			else if (touch.phase == TouchPhase.Ended && Finger1) {	
				
				Finger1 = null;
			}
		}
		}



}

how can i do this working with two fingers?
sorry for bad english, i’m italian :wink:

You can try this in LateUpdate() Function :

void LateUpdate(){
    if (Input.touchCount >= 2) {
        Vector3 finger1 = Input.GetTouch(0);
        Vector3 finger2 = Input.GetTouch(1);

        // now you can do the rest of the code for each touch
    }
}

Hope it works… :slight_smile: