I'm currently developing unity 2d platformer game for android. Then, i'm implement touch control with screen position detection.
![alt text][1]
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();
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;
}
}
[1]: /storage/temp/22842-side.png
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.
↧