- Home /
How to prevent multiple button clicks at the same time?
Hi, I've created a simple quiz game for Android. There are 4 answers for each question and only one of them is true. Now my problem here is that when I click or touch two answers(buttons) at the same time, both of them behave and do the function which I've written. How can I prevent this kind of behavior?
This may not suit your script or may already what you are doing but replacing if with a chain of if else statements can prevent this behavior. something like this pseudo code.
if (button a is clicked)
do a logic
else if (button b is clicked)
do b logic
when doing the button logic one thing that can be tried then is to add a bool that becomes true and blocks another button press the next frame. Then make the bool false for the next question.
Your answer
![](https://koobas.hobune.stream/wayback/20220612122807im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
GUI.Button press (not click) 3 Answers
Default Android touch sound 0 Answers
Trying to make Quizlike game. Click on object, get right or wrong response 0 Answers
GUI Texture Pause Button 0 Answers
mouse clicked on object animation c# 1 Answer