So I’m trying to make a game where you need to control 2 objects, I managed to make obects to folow only one finger at time.
heres the code :
void Update () {
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved){
x = Input.GetTouch(0).position.x;
y = Input.GetTouch(0).position.y;
Vector3 move = Camera.main.ScreenToWorldPoint(new Vector3(x, y, 0));
transform.position = new Vector3(move.x, move.y);
}
if (Input.touchCount == 2 && Input.GetTouch(1).phase == TouchPhase.Moved){
x1 = Input.GetTouch(1).position.x;
y1 = Input.GetTouch(1).position.y;
Vector3 go = Camera.main.ScreenToWorldPoint(new Vector3(x1, y1, 0));
Obj.transform.position = new Vector3(go.x, go.y);
}
}