Hello, I’m trying to detect/get the last/latest touch. I don’t need anything else just the latest touch.
Are there any easy way to do that?
Hello, I’m trying to detect/get the last/latest touch. I don’t need anything else just the latest touch.
Are there any easy way to do that?
input.gettouches
Hmm to be clear, what I want to do is: User touches the screen with one finger lasttouch = that touch User touches the screen with 2nd finger while first one still on the screen lasttouch = 2nd finger User releases first finger from screen lasttouch = 2nd finger still User touches screen with finger again now lasttouch = current finger
The problem is that, when you put 1st finger then 2nd, when you release 1 finger last index is correct finger, but when user touches again, last index is still the previous finger because I think unity prepends the list because he was touched with his finger before…
Input.GetTouch(Input.touchCount-1) doesnt work because of that…
I tried something like this but the way that it works sucks… Need a better way…
void Update()
{
for(int i = 0; i < Input.touches; i++) {
if(Input.touches[i].phase == TouchPhase.Began)
{
lastFingerIndex = Input.touches[i].fingerId;
}
if(Input.touches[i].fingerid == lastFingerIndex)
{
lastIndex = i;
}
}
Touch lastTouch = Input.GetTouch(lastIndex);
}