So at the moment, I’m making a small little mobile game and I have a scorer working. What I want to do is to make the scorer accelerate (score faster) when the numerical value of score has reached a certain threshold. I used a vector3 to represent the 3 thresholds at which point the scorer will score faster. The problem is, whenever the score has reached threshold#1, it stops counting. Can someone please evaluate my script?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextController : MonoBehaviour {
public GameObject Player;
public Vector3 ScoreTargets;
private float Score;
public Text Self;
IEnumerator Scorer(){
while(Score < ScoreTargets.x){
Score += 25;
Debug.Log(Score);
yield return new WaitForSeconds(.1f);
}
while(Score < ScoreTargets.y && Score > ScoreTargets.x){
Score += 100;
Debug.Log(Score);
yield return new WaitForSeconds(.1f);
}
while(Score < ScoreTargets.z && Score < ScoreTargets.y && Score < ScoreTargets.x){
Score += 150;
Debug.Log(Score);
yield return new WaitForSeconds(.1f);
}
yield return new WaitForSeconds(1);
}
void Start () {
StartCoroutine("Scorer");
}
// Update is called once per frame
void Update () {
Self.text = "Score: " + Score;
}
}
here’s a little video of what’s happening. Just skip near the end to see the counter stop