I’m fairly new to Unity and have only been dependent on online sources to help me
Lately, I have been stuck with one problem where I wanted to display a random tip on my game every 10s with a display time of 5s
I made a rng that is supposed to generate a number every 10s, but now after the first generation it goes haywire and generates multiple random numbers
I’d appreciate it if you can help thank youuuu
public GameObject T1;
public GameObject T2;
public GameObject T3;
public GameObject T4;
private int RanTip;
private GameObject CurTip;
void Start () {
T1.SetActive (false);
T2.SetActive (false);
T3.SetActive (false);
T4.SetActive (false);
}
void Update () {
InvokeRepeating ("Randomizer",10,10);
Debug.Log ("Randomizing");
}
void RNG(){
if (RanTip==0){
CurTip = T1;
CurTip.SetActive (true);
StartCoroutine ("DisplayTime");
Debug.Log ("1");
}
else if (RanTip==1){
CurTip = T2;
CurTip.SetActive (true);
StartCoroutine ("DisplayTime");
Debug.Log ("2");
}
else if (RanTip==2){
CurTip = T3;
CurTip.SetActive (true);
StartCoroutine ("DisplayTime");
Debug.Log ("3");
}
else if (RanTip==3){
CurTip = T4;
CurTip.SetActive (true);
StartCoroutine ("DisplayTime");
Debug.Log ("4");
}
}
IEnumerator DisplayTime (){
yield return new WaitForSecondsRealtime (5f);
CurTip.SetActive (false);
}
void Randomizer (){
RanTip = Random.Range (0,3);
RNG ();
}
}