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