Making Dual Touch Input more lenient
Hi there,
I'm currently working on a dual tap mechanic for my mobile project and the current code that I'm using works but it requires both touches to be lifted simultaneously at the precise frame in order to function which to do consistently is inhuman.
void Update()
{
if (Input.touchCount > 1)
{
Touch tOne = Input.GetTouch(0);
Touch tTwo = Input.GetTouch(1);
{
if(tOne.phase == TouchPhase.Canceled && tOne.position.x < screenWidth && tTwo.phase == TouchPhase.Canceled && tTwo.position.x > screenWidth)
{
print("Dual Tap");
}
else if (tOne.phase == TouchPhase.Canceled && tOne.position.x > screenWidth && tTwo.phase == TouchPhase.Canceled && tTwo.position.x < screenWidth)
{
print("Dual Tap");
}
}
}
}
I want to make the input more forgiving for players to apply a dual touch input without it being so frame precise. I've tried looking into how touch.fingerId works, thinking that I need to store each finger used to create a function to cut some slack but there is not too much info for this with a quick google search so if anyone could help me on this it would be greatly appreciated!
PS: I was previously using TouchPhase.Ended but it seem to be not as responsive compared to Cancelled.
Your answer
![](https://koobas.hobune.stream/wayback/20220612204651im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Problems with touch input. 0 Answers
Working with multiple joystick models 0 Answers
How to clear the keyboard buffer 1 Answer
HELP PLEASE! beginner 3 Answers
How do I make joystick and keyboard controls equivalent to one another? 0 Answers