- Home /
disable multi touch on specific screen area
I'm currently developing unity 2d platformer game for android. Then, i'm implement touch control with screen position detection.
as you see, i split the screen to 3 pieces : 1 for move to left, 2 for move to right, and 3 for jump. here the lines :
void Start ()
{
anim = gameObject.GetComponent<Animator>();
w = Screen.width;
h = Screen.height;
}
void Update ()
{
if (Input.touchCount > 0) {
while (k < Input.touchCount) {
if (Input.GetTouch (k).position.y > h / 3 && Input.GetTouch (k).position.x < w / 2 ) {
// Move your character right
moveToRight();
}
if (Input.GetTouch (k).position.y > h / 3 && Input.GetTouch (k).position.x > w / 2 ) {
// Move your character left
moveToLeft();
}
if (Input.GetTouch (k).position.y < h / 3 && anim.GetBool ("Grounded")) {
// jumping
jumpPlayer();
}
++k;
}
}
The script jus fine, work normally. But for any reason i want to disable multi touch finger on area 3, i have seen unity docs for disable multi touch : Input.multiTouchEnabled = false;
, then i asign that bool to Jumping touch control (area 3) :
if (Input.GetTouch (k).position.y < h / 3 && anim.GetBool ("Grounded")) {
// jumping
Input.multiTouchEnabled = false;
jumpPlayer();
}
for any reason too, i assign Input.multiTouchEnabled = true
on touch area 1 and 2. But not that i want. Every i touch area 3, multi touch is disable, but when i touch area 1 or 2, on area 3 it's still enable to multi touch. I Know the problem, because i set Input.multiTouchEnabled = true
on touching area 1 and 2. but, it's not possible to set false
multi touch on touching area 1 and 2. And finally, i have conclusion to disable multiTouch
on screen area 3 (not with touch, but permanently). question is : How to disable multi touch on specific screen area ?, in this case on area number 3. any answers would be very helpful. Thanks.
I think the multi touch2 of that android is low in quality so thats why i prefer touch3 which is much useful for me .
For what do you need such complicated behaviour? I think there are beter way to do what you need. Am I right and you need to avoid calling moveToLeft() and moveToRight() functions when player hits Jump?
Because every i'm hit the jump screen with double fingers or more, it's calculate jump power with amount of fingers.
Your answer
![](https://koobas.hobune.stream/wayback/20220613135000im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make Mobile Touch Controls work when pressing the left and right side of the screen 1 Answer
Make an obect take priority over another when touched? 0 Answers
How to convert mouse input to mobile touch in unity 1 Answer
How click and drag a 2D game object without click and dragging the Camera Orthographic? 1 Answer
Images are invisbles in Scene but visibles in Game preview 2 Answers