I am having 4 textures as player controls in my scene on which I am trying to detect touches using the following code:
//left,right,attack,jump are textures;
for (int i = 0; i< Input.touches.GetLength(0); i++) {
if (left.HitTest (Input.GetTouch (i).position) && Input.GetTouch (i).phase != TouchPhase.Ended) {
//player.SendMessage ("Move", -1);
}
if (right.HitTest (Input.GetTouch (i).position) && Input.GetTouch (i).phase != TouchPhase.Ended) {
//player.SendMessage ("Move", 1);
}
if (!right.HitTest (Input.GetTouch (i).position) && !left.HitTest (Input.GetTouch (i).position)) {
//player.SendMessage ("Move", 0.0f);
}
if (jump.HitTest (Input.GetTouch (i).position) && Input.GetTouch (i).phase == TouchPhase.Began) {
//player.SendMessage ("Jump", true);
}
if (attack.HitTest (Input.GetTouch (i).position)) {
//player.SendMessage ("AttackKeyPressed", true);
}
}
The problem I am getting is that I am unable to detect simultaneous touches on 2 textures like left and jump texture. touching the jump textures stops the left texture action.
How can I do this?
Or is there any better strategy to implement this?