Strange Multi-Touch Behaviour.

Hello everyone does anyone know why this script makes multi touch behave weird. Whoever puts their finger first they can move flawlessly. Second touch can still move but very stiff and laggy and not 1 to 1. Soon as first touch is lifted now the second touch player can move flawlessly…and vice versa. Please advise thank you.

using UnityEngine;
using System.Collections;


public class TouchDrag : MonoBehaviour {
   
    public float speed=0.01f;
   
    public Transform Player01;
    public Transform Player02;
    Rect halfLeft = new Rect(0,0, Screen.width / 2, Screen.height);
    Rect halfRight = new Rect(Screen.width/2,0F,Screen.width/2,Screen.height);
   
    void FixedUpdate(){
       
       
       
        if (Input.touchCount > 0) {
            for(int i = 0; i < Input.touchCount; i++ ) {
                Touch theTouch = Input.GetTouch(i);
                int fingerId = theTouch.fingerId;
               
               
               
                if (halfLeft.Contains(theTouch.position) && theTouch.phase == TouchPhase.Moved && (fingerId==0||fingerId==1) ) {
                   
                    Vector2 touchDeltaPositionL = theTouch.deltaPosition;
                   
                    Player01.transform.Translate(0,touchDeltaPositionL.y * speed, 0);
                   
                }
               
                if (halfRight.Contains(theTouch.position) && theTouch.phase == TouchPhase.Moved && (fingerId==0||fingerId ==1)) {
                   
                    Vector2 touchDeltaPositionR =theTouch.deltaPosition;
                   
                    Player02.transform.Translate(0,touchDeltaPositionR.y * speed, 0);
                   
                }
               
               
            }           
           
           
        }
       
    }
   
}

I wouldn’t make any assumptions about fingerId being 0 or 1 - as far as I know it could be any value even if you only had 2 fingers on screen. It’s probably worth changing your code to detect the ‘finger down’ touch phase and then store the fingerId at that bottom based on which side of the screen the finger went down. That way you can track that fingerId as belonging to a particular player.

So before I do the touchphase.moved I should do this

if(touch.phase == TouchPhase.Began && fingerId == -1) {

Sheesh headache just small part of game cant even move two objects properly! Lol just simple movement like similar to games like multi touch pong or air hockey.