Question by
KristianGrytdal · Aug 08, 2016 at 01:43 PM ·
c#script.counter
how to make a max number on counter.
I have a program that counts guesses, but it's just supposed to go to 20. But now it goes on forever, have can I make it max out at twenty. Thank in advance :)
Comment
Answer by csalzman · Aug 08, 2016 at 03:02 PM
You can clamp a value between a minimum and maximum number:
http://docs.unity3d.com/ScriptReference/Mathf.Clamp.html
Mathf.Clamp(guesses, 0, 20)
My guess is what you really want to do is to make something else happen when you reach 20 guesses.
if(guesses == 20) {
runAnotherFunction();
}
For more on conditionals check out the Unity tutorials, they're quite good!