Hi folks, i’ve a problem with a script. He show me an error:
NullReferenceException: Object reference not set to an instance of an object
ColpiLeft.UpdateGUI () (at Assets/Scripts/HUD/ColpiLeft.js:12)
I’m trying to call a function from another script without declaring static variables. The GetBulletsLeft() function return the bullets left. Can someone help me, please?
This is the js code!
private var weapon : WeaponControl;
function Awake(){
weapon = new GetComponentInChildren(WeaponControl);
}
function LateUpdate(){
UpdateGUI();
}
function UpdateGUI(){
guiText.text = "Prova"+weapon.GetBulletsLeft().ToString();
}