Question by
rickyxd · Dec 29, 2016 at 04:47 PM ·
androidtouchjumpmouse click
Unity game doesn't detect every click
Hi everyone! I'm trying to create a 2d game with a player ( a ball ) that jumps when I touch the screen. I accomplish this with :
if (Input.GetMouseButtonDown (0)||Input.GetKeyDown("space")) {
gameObject.GetComponent<Rigidbody2D>().velocity=Vector.up*speed;
gameObject.GetComponent<AudioSource>().Play();
}
(The code is in Update()) There isn't any type of problem in the Editor, but when I debug the game on my Android phone the ball doesn't jump every time I touch the screen and, due to the gravity, it fall down, as if I had not touched. In particular I noticed that the problem is more evident after some minutes of play, or every time I realod the level. I've tried many things but none helped me. What am I doing wrong?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612103651im_/https://answers.unity.com/themes/thub/images/avi.jpg)