- Home /
Android touch is not dynamic
The game: just spheres going around the screen(with a random speed, usually something like 10*time.deltaTime) On pc when i click with the mouse on them i can pretty much touch all of them pretty quick. but on android i click and there is like some sort of delay or its not clicking properly. The code:(javascript)
if(Input.GetMouseButtonDown(0)){
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if(Physics.Raycast (ray, hit)){
Destroy(hit.collider.gameObject);//Destroys the sphere
}
}
(The code works, but when i try to click on the spheres(there is something around 5- 10) its undynamic, i mean i can touch them but its not destroying them. Any help apperciated
Are you trying from Unity Remote or actually building it to android? Unity Remote can have delay and inconsistency issues.
But i want to delete it ONLY when i touch the sphere. Just changed it to plane, i thought it will maybe be better but its pretty much the same
@Sir$$anonymous$$urt is correct - unless your Android device has a mouse, don't use Get$$anonymous$$ouseButtonDown. Use proper touch-handling code ins$$anonymous$$d.
Answer by KurtGokhan · Jan 17, 2015 at 08:48 PM
Can you try touch methods? Your code should be:
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){
var ray = Camera.main.ScreenPointToRay (Input.GetTouch(0).position);
var hit : RaycastHit;
if(Physics.Raycast (ray, hit)){
Destroy(hit.collider.gameObject);//Destroys the sphere
}
}
Your answer
Follow this Question
Related Questions
Android touch question 0 Answers
android touch input 1 Answer
Unity 2D Mobile Game Drawing Mechanic 0 Answers
Converting screen coordinates to world coordinates 1 Answer
Executing Code Once Per Touch 1 Answer