Hi, thank you for taking the time to read this post! I have a script that is supposed to add 1 to an int everytime the countdown hits 0. This same exact script with 0 changes worked 2 hours ago, I got up to eat dinner and it no longer counts the waves properly. The debug still prints properly every time but it is no longer printing the value and possibly just not increasing it. I have a similar script used to track the money and score of my game that is written in almost the exact same way other than the value that’s being increased. I have made sure that the script is attached to the text and that the text is the right TMP being printed. This has to just be me overlooking something basic, thank you for the help!
There are 2 scripts that are supposed to increase the int and one to print it, this is the Spawner that is supposed to increase the int in the Stats script, then the TMP script should pull the current value and display it.
using UnityEngine;
using TMPro;
public class Spawner : MonoBehaviour
{
public Wave[] waves;
private int currentWaveIndex = 0;
[SerializeField] private GameObject spawnPoint;
[SerializeField] private float countdown;
public TextMeshProUGUI waveCountDownText;
private bool readyToCountDown;
private void Start()
{
for (int i = 0; i < waves.Length; i++)
{
waves[i].enemiesLeft = waves[i].enemies.Length;
}
}
private void Update()
{
waveCountDownText.SetText(countdown.ToString("00.00"));
countdown -= Time.deltaTime;
countdown = Mathf.Clamp(countdown, 0f, Mathf.Infinity);
if (countdown <=0)
{
countdown = waves[currentWaveIndex].timeToNextWave;
currentWaveIndex++;
StageStats.Rounds++;
StartCoroutine(SpawnWave());
}
}
private IEnumerator SpawnWave()
{
for (int i = 0; i < waves[currentWaveIndex].enemies.Length; i++)
{
Instantiate(waves[currentWaveIndex].enemies[i], spawnPoint.transform);
yield return new WaitForSeconds(waves[currentWaveIndex].timeToNextEnemy);
}
}
}
[System.Serializable]
public class Wave
{
public Enemy[] enemies;
public float timeToNextEnemy;
public float timeToNextWave;
public int enemiesLeft;
}
This is the script that houses the stats
using UnityEngine;
public class StageStats : MonoBehaviour
{
public static int Money;
public static int Score;
public int startScore = 0;
public int startMoney = 500;
public static int Lives;
public int startLives = 100;
public static int Rounds;
void Start ()
{
Money = startMoney;
Score = startScore;
Lives = startLives;
Rounds = 0;
}
}
This is the script that’s supposed to print to the selected TMP
using UnityEngine;
using TMPro;
public class WaveCount : MonoBehaviour
{
public TextMeshProUGUI waveText;
void update()
{
waveText.SetText(StageStats.Rounds.ToString());
}
}
I’m sorry again for the basic question I just have 0 idea why this stopped increasing the count but still does the Coroutine and prints the debug. I can also post the money script that’s using the same method to print to the TMP. That used StageStats.Score += value; instead of StageStats.Round++; . Like I said I have touched nothing and this worked before I got up?? Is there a wizard breaking my script?? lmaoo thank you again for reading and for any help!