i want to make one simple game.
it is very easy.
there are 2 button left and right bottom
randomly one of this two buttons apear if you press on time you earn 1 points if you cant press you lost -2 point.
if you press wrong button you lost -2 points too.
how can i make this
public gameObject myButton1;
public gameObject myButton2;
private bool processButton1 = true;
private bool processButton2 = true;
void Awake(){
myButton1.setActive(false); //INITIALIZE HIDDEN
myButton2.setActive(false);
}
void Update(){
if(processButton1){ //IF WE SHOULD BE CHECKING
if(Random.value < 0.5f){ //PICK A RANDOM NUMBER BETWEEN 0.0f to 1.0f
processButton1 = false; //STOP CHECKING
myButton1.setActive(true); //SHOW THE BUTTON
StartCoroutine(DelayHideButton1()); //AFTER A WHILE HIDE THE BUTTON
}
}
if(processButton2){
if(Random.value > 0.5f){
processButton2 = false;
myButton2.setActive(true);
StartCoroutine(DelayHideButton2());
}
}
}
IEnumerator DelayHideButton1() {
yield return new WaitForSeconds(0.5f); //WAIT HALF A SECOND
myButton1.setActive(false); //HIDE THE BUTTON
processButton1 = true; //AGAIN RUN Update() TO SEE IF WE SHOULD SHOW IT AGAIN
}
IEnumerator DelayHideButton2() {
yield return new WaitForSeconds(0.5f);
myButton2.setActive(false);
processButton2 = true;
}
1 Like
ty mate.
i try it.
i am very new of coding. actualy i am very old to learn (30 years old). but i want something and i realize i have start somewhere.
i am very good at make terrain but very bad at coding.
ty reply my message