For some odd reason, my If statement in the Paddle class keeps giving me an error. The error says "NullReferenceException: Object reference not set to an instance of an object". I cant wrap my head around this problem. I need to get the Boolean value of "isBlue" from the Ball Class into the Paddle class. Once it is in the Paddle class, I need to use that boolean value to transform a texture. Any Help would be greatly Appreciated. Thanks
//Paddle class
#pragma strict
var blue: Texture;
var isBlue: boolean = false;
Public var newBall : Ball;
function Start () {
}
function Update () {
newBall = GetComponent(Ball);
isBlue = newBall.isBlue;
if(isBlue == true)
{
renderer.material.mainTexture = blue;
}
}
Ball Class
var blue : Texture;
var isBlue : boolean = false;
function OnCollisionEnter(col : Collision){
if(col.collider.name == "Brick3"){
Destroy(col.gameObject);
score += 10;
guiScore.text= "Score: " + score;
renderer.material.mainTexture = blue;
isBlue = true;
}
}