- Home /
Question by
LordOfGears2 · Dec 23, 2013 at 07:48 AM ·
androidinput
How to allow clicking of 2 buttons at once in Android
Here is my code:
function Update () {
var touchCount = Input.touchCount;
for(var i=0; i<touchCount;i++ ){
var touch = Input.GetTouch(i);
if(touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Stationary){
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray,hit)){
if(hit.point.y < 0){ //Check the Y because this is for a game
//for 2 players, one at the top on at the bottom
transform.position.x = hit.point.x;
}
}
}
}
}
Comment
I found a way that works, here is my code in case someone else has a similar problem.
for (var i = 0; i < Input.touchCount; ++i) {
ray = Camera.main.ScreenPointToRay (Input.GetTouch(i).position);
if (Physics.Raycast (ray, hit)) {
if(hit.point.y < 0){
transform.position.x = hit.point.x;
}
}
}
Your answer
Follow this Question
Related Questions
Android Input 1 Answer
Android to unity INPUT 0 Answers
SendMouseEvents.DoSendMouseEvents() allocates garbage every frame 1 Answer
Android Action Button 2 Answers
A node in a childnode? 1 Answer