first of all here is the script
public Text Redtext;
public Text Bluetext;
public Text Bigtext;
bool RedisOn;
bool BlueisOn;
public float delayTimer;
public float spwanMostwait;
public float spwanlesswait;
float timer;
int RedScore;
int BlueScore;
void Start () {
StartCoroutine (Spwaner ());
timer = delayTimer;
RedScore = 0;
BlueScore = 0;
}
// Update is called once per frame
void Update () {
Redtext.text = " " + RedScore;
Bluetext.text = " " + BlueScore;
delayTimer = Random.Range (spwanlesswait,spwanMostwait);
timer -= Time.deltaTime;
if (timer <= 0) {
if (delayTimer < 10) {
RedText ();
timer = delayTimer;
}
if (delayTimer > 11) {
BlueText ();
timer = delayTimer;
}
}
}
public void RedText (){
Bigtext.text = "Red";
RedisOn = true;
BlueisOn = false;
}
public void BlueText(){
Bigtext.text = "Blue";
RedisOn = false;
BlueisOn = true;
}
void OnCollisionEnter2D (Collision2D col) {
if (RedisOn == true && BlueisOn == false) {
if (col.gameObject.tag == "Red") {
RedScore += 1;
}
if (col.gameObject.tag == "Blue") {
Destroy (gameObject);
}
}
if (BlueisOn == true && RedisOn == false) {
if (col.gameObject.tag == "Blue") {
BlueScore += 1;
}
if (col.gameObject.tag == "Red") {
Destroy (gameObject);
}
}
}
IEnumerator Spwaner() {
while (true) {
yield return new WaitForSeconds (delayTimer);
}
}
my problem is the “BigText” doesn’t show , which means that the delayTimer doesn’t respond.
but when I change the delaytimer to timer in the if (delayTimer < 10) line, it works but I get no Random, I tried everything here but no solution so how I make this work so I get random text shown.