Unity 2D game when transfered from PC to Android dialogues changes too fast!
void Update () {
if (dialogueActive && Input.touchCount == 1 || Input.GetKeyUp(KeyCode.Space))
{
currentLine++;
}
I have a dialogue in the game and on the phone when I touch the screen one time it doesn't go to the next line but to the 4th or 5th dialogue line. In PC with spacebar button it's not a problem.
And I want it to change one dialogue line when pressed on the screen!
I would put button over the screen with Alpha set to zero. Button is much more reliable because in your case it's probably counting multiple touches even if for you it seems like one.
Answer by HarshadK · Dec 07, 2016 at 02:11 PM
The case here is that when you touch your finger on the screen the touchCount
becomes 1 till you lift your finger. And since you are executing the above if
condition in Update the currentLine
will increment each frame till you lift your finger.
One way to counter this is to increment the currentLine
only when user has lifted his finger by checking for TouchPhase.Ended
.
Check example on this Input.touches page.
Your answer
![](https://koobas.hobune.stream/wayback/20220612102215im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
TouchPhase.Began hold problem 0 Answers
iphone 6/6s plus touch issue 0 Answers
How do I make a rigid body move towards position of touch 0 Answers
Rotate and object with Touch 0 Answers
Move a cube on android 0 Answers