I have two scripts. I’ve looked through various questions and got no help for it whatsoever. I haven’t coded in a good few months, So i’m a bit rusty.
I have the updater for the text under Update(), And i checked that it updates at least once, However, It gets stuck at 100.
Here are my two scripts:
Sanity.cs:
`
using UnityEngine;
using System.Collections;
public class Sanity : MonoBehaviour {
int SanityLevel = 100;
int Wave = 1;
public static int EnemiesDefeated = 0;
int WaveRequirement = 10;
public static int TotalEnemiedDefeated = 0;
public static string SanityString;
// Use this for initialization
void Start () {
SanityString = SanityLevel.ToString ();
InvokeRepeating("SanityDecrease", 0, 1);
//InvokeRepeating("OnGUI", 0, 1);
}
// Use this for GUI
/*void OnGUI () {
GUI.Label (new Rect (10, 10, 100, 20), "Sanity: " + SanityString);
}*/
// Update is called once per frame
void Update () {
if (EnemiesDefeated == WaveRequirement) {
SanityLevel += WaveRequirement;
EnemiesDefeated = 0;
WaveRequirement += WaveRequirement;
}
}
void SanityDecrease(){
SanityLevel -= 1;
}
}
`
SanityDisplay.cs:
`
using UnityEngine;
using System.Collections;
public class SanityDisplay : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
guiText.text = "Sanity :" + Sanity.SanityString;
}
}
`
SanityDisplay.cs is supposed to update the amount of sanity left. Sanity.cs is supposed to handle sanity, the wave, and how many enemies have been killed.