Hello, I have a problem with GUIText. Currently in my code i have an EXP system in which currentXP is being added +1 everytime function Update runs. My player(playerPrefab) has the Levelsystem script on it and works fine. But when i start the game, the GUIText does not update until i exit out of the game. My playerPrefab has the Component of the level script and has a GUI Layer on it. I have an GUIText that i made into a prefab and added it to the guiTextEXP and to the hierarchy. Is there a way for real time updating like while moving?
SPAWN SCRIPT/NETWORK MANAGER
function spawnPlayer1(){
Network.Instantiate(playerPrefab, spawnObject.position, Quaternion.identity, 0);
camHarness = GameObject.Find("CamHarness");
Debug.Log(camHarness.ToString());
cam.transform.parent = camHarness.transform;
cam.transform.parent = playerPrefab.GetComponent("CamHarness");
playerPrefab.GetComponent("MouseLook");
playerPrefab.AddComponent("LevelSystem"); // LevelSystem is the EXP script. It just adds 1 to a variable every time it loops
playerPrefab.GetComponent("LevelSystem");
LEVEL SCRIPT
var guiTextEXP: GUIText;
var guiTextLevel:GUIText;
var currEXP : int = 0;
var maxEXP : int = 100;
var currentLevel : int = 1;
var levelUp = false ;
function Start(){
}
function Update () {
currEXP++;
if(currEXP >= maxEXP) {
currentLevel += 1;
levelUp = true;
}
if (levelUp){
maxEXP *= 1.2;
currEXP = 0;
levelUp = false;
}
guiTextEXP.text = "EXP:" + currEXP+" / " + maxEXP;
guiTextLevel.text = "Level: " + currentLevel;