For example, we press four fingers on the screen in sequence, finger1, finger2, finger3, finger4
At this time, in the order of finger1=input.GetTouch(0); finger1.fingerId=0; ; finger2 = input.GetTouch(1); finger2.fingerId = 1 ; finger3 = input.GetTouch(2); finger3.fingerId=2 ;finger4 = input.GetTouch(3); finger4.fingerId=3;
It should be noted that when the finger does not leave the life cycle of the screen, its fingerId is unchanged; (if the finger clicks quickly and continuously, similar to double-clicking, it also remains unchanged)
But the index of input.GetTouch(index) may change.
test:
When raising finger1:
In input.GetTouch(index), the index has changed
finger2=input.GetTouch(0); finger2.fingerId=1; index changes from 1=>0, fingerId remains unchanged
finger3=input.GetTouch(1); finger3.fingerId=2; index changes from 2=>1, fingerId remains unchanged
finger4=input.GetTouch(2); finger4.fingerId=3; index changes from 3=>2, fingerId remains unchanged
When pressing the finger again (not referring to a specific finger)
finger1=input.GetTouch(0); finger1.fingerId=0;
finger2=input.GetTouch(1); finger2.fingerId=1; index changes from 0=>1, fingerId remains unchanged
finger3=input.GetTouch(2); finger3.fingerId=2; index changes from 1=>2, fingerId remains unchanged
finger4=input.GetTouch(3); finger4.fingerId=3; index changes from 2=>3, fingerId remains unchanged
When lifting two fingers finger2 and finger3
finger1=input.GetTouch(0); finger1.fingerId=0; index remains unchanged, fingerId remains unchanged
finger4=input.GetTouch(1); finger3.fingerId=3; index changes from 3=>1, fingerId remains unchanged
Then press finger3 first, then finger2
finger1=input.GetTouch(0); finger1.fingerId=0; index remains unchanged, fingerId remains unchanged
finger2=input.GetTouch(2); finger2.fingerId=2; index from 1=>2, fingerId from 1=>2
finger3=input.GetTouch(1); finger3.fingerId=1; index from 3=>1, fingerId from 2=>1
finger4=input.GetTouch(3); finger3.fingerId=3; index changes from 3=>1, fingerId remains unchanged
After testing, it was concluded:
1. When the finger is pressed continuously, the life cycle has not ended and the fingerId remains unchanged.
2. When the finger is pressed, the index corresponding to input.GetTouch(index) may change.
3. When multiple fingers are pressed in sequence, the fingerId array is essentially allocated according to the unreferenced values from first to last. For example, fingerID{0,2,3} already exists, and if another finger is pressed, the fingerID will be reassigned. {1}.
4. When multiple fingers are pressed and the middle finger is lifted, the index behind it will move forward, such as input.GetTouch(2), fingerId=2, if this finger is lifted, then the corresponding input.GetTouch( 3) The finger index becomes input.GetTouch(2), and the fingerId remains unchanged.
5. It can be understood that fingerId corresponds to an array f1, and GetTouch corresponds to an array f2. f2 is copied in the order of f1. For example, f1{0,4,5}, f2{0,1,2}, then the corresponding f2 is f2[0]=f1[0], f2[1]=f1[1], f2[2]=f1[ 2]. That is, input.GetTouch(0)=f1{0}, input.GetTouch(1)=f1{4}, input.GetTouch(2)=f1{5}