For some reason this script is messing me up
public static PlayerInformationController PFC;
void OnGUI() {
GUI.Label(new Rect(10, 70, 100, 20), "Dollars = " + PFC.curMoney);
}
I believe that all of the is correct and i get no errors but when i go into debug mode i get billions of these
NullReferenceException: Object reference not set to an instance of an object
MyGUI.CharacterSkillsGUI () (at Assets/ShiftedIrony Assets/Scripts/PlayerScripts/MyGUI.cs:143)
MyGUI.OnGUI () (at Assets/ShiftedIrony Assets/Scripts/PlayerScripts/MyGUI.cs:59)
Don't really know what is messing it up but atm im trying to fix. that small script is not the entire script its just the part the the problem is located in. i don't think i need it to be public static but i put it in there anyways either way i get that error.
EDIT:
PFC SCRIPT
using UnityEngine;
using System.Collections;
public class PlayerInformationController : MonoBehaviour {
public int curMoney = 0;
public int curHealth = 100;
public int maxHealth = 100;
private string PlayerName = "Test";
public GUIText CharacterChat;
public Transform playerSpawn;
public static MyGUI mg;
public float healthBarLength;
void Start () {
healthBarLength = Screen.width;
}
// Update is called once per frame
void Update () {
AdjustCurrentHealth(0);
}
void OnGUI() {
GUI.Label(new Rect(10, 10, 100, 20), PlayerName);
GUI.Box(new Rect(10, 30, Screen.width / 16, 20), curHealth + "/" + maxHealth);
}
public void AdjustCurrentHealth(int adj) {
curHealth +=adj;
if(curHealth < 1)
curHealth = 0;
if(curHealth == 0)
transform.position = playerSpawn.position;
if(curHealth == 0)
curHealth = maxHealth;
if(curHealth > maxHealth)
curHealth = maxHealth;
if(maxHealth < 1)
maxHealth = 1;
}
}