I’m having an issue with multitouch for my game, which consists of multiple modes. The basic premise of the whole game is to hit square pads in a grid as they light up (as a test of reflexes, reaction time etc). In some game modes where multitouch is enabled, if the player simultaneously makes two touches OR if they touch two or more fingers down, it appears to send the touch command over and over and over, spamming the pads (which flash red if they were unlit and touched).
Is there a way I can cancel previous touches once a new touch is made? Or anything I can do to avoid multiple simultaneous touches on the screen to spam the pads like they are doing? Cheers for the help.
Here is my touch input code, the first half of which handles mouse clicks and non-multi touch modes.
// Touch inputs and multitouch when enabled
if(Input.touchCount < 2){ // Code for detecting mouse input, primarily for testing
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray.origin, ray.direction,hit)){
if(Input.GetMouseButtonDown(0)) {
InputHandler(hit); // Function handling all registered pad hits
}
}
}else if(multiTouch) { // Code for detecting multiple touch inputs
var touchMax : int = 4; // Max 4 touches for multitouch modes to avoid spamming
for(var i = 0; i < touchMax; i++){
ray = Camera.main.ScreenPointToRay(Input.touches*.position);*
-
if(Physics.Raycast(ray.origin, ray.direction,hit)){*
-
InputHandler(hit); // Function handling all registered pad hits*
-
}*
- }*
}