I am very new to programming and struggling with a problem. I am trying to access the variable "score" from one script and use "score" to determine the height of a guitexture on another script. I have tried it a couple ways but i keep getting this error: Null Reference Exception: Object reference not set to an instance of an object.
This is how my script is written.
//this is my first script, which is named: stonyScript
var score : float = 0;
function OnCollisionEnter(col : Collision){
if(col.gameObject.name == ("asteroid")){
score += 10;
}
//here is the second script.
currentHeight = stonyScript.js.score;
function Update(){
guiTexture.pixelInset.width = 20;
guiTexture.pixelInset.height = 10 + currentHeight;
}
↧