click wrong button lose a life
im creating a word game.wherein if you click the wrong button ( the button which is not belong to the answer) you will lose 1 life. you only have 3 lives. can somebody help me with my codes ? much appreciated.
Well, you've given way too little details. At this point I can only tell you yhay you'd need to attach a function that checks if the button is correct or not to the OnClick event of each button. the function needs to either call the Correct()
method -- if user clicks correct answer, or LoseLife()
when user makes wrong choice.
@$$anonymous$$rReynevan2 can you please show me the code. if i have 3 life and whenever i click the wrong button i will lose 1 life. ,@$$anonymous$$rReynevan2 can you please give me a code for c# wherein if i click the wrong button i will lose one life. take not i only have 3 lives
Answer by Bogsse · Aug 01, 2016 at 02:08 PM
Assuming it is c# you are coding i have code here that would work.
private int Health = 3;
public void Correct() {
return;
}
public void inCorrect() {
Health = Health - 1;
if (Health == 0) {
Die();
}
}
public void Die() {
//Kill Player
}
You can do the rest assuming you know how to code to.
Your answer
![](https://koobas.hobune.stream/wayback/20220612085940im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is it better to come in this field as a designer or an engineer?? 0 Answers
Enemy is loosing life when he's gun is shot 0 Answers
Ennemy don't lose life [C#] 1 Answer
Adding to variable only once? 0 Answers
Help with Collider? 2 Answers