Does anyone know how to fix this if statment?

Basically, I am Making a brick breaker game and need the ball to break brick2 only if the ball has already broken brick 3. Once the ball has broken Brick 3 the texture turns blue. I have it so that if Texture == blue then do everything in this block. but for some reason when I run the program, that block never seems to execute. I have no Compilation errors. I think its a logic problem. Does anyone know a soloution to my problem? The program does not seem to understand if(Texture==blue) although it compiles it fine

 var blue : Texture;
 
 function OnCollisionEnter(col : Collision){

 if(col.collider.name == "Brick3"){
 Destroy(col.gameObject);
 score += 10;
 guiScore.text= "Score: " + score;
 renderer.material.mainTexture = blue;
 }

 if(col.collider.name == "Brick2" && Texture == blue){

 Destroy(col.gameObject);
 score += 10;
 guiScore.text= "Score: " + score;
 print("collided with brick");

}

}

Your statement Texture == blue refers to the Texture class, not an object. You probably need to address that a bit better (for instance: renderer.material.mainTexture).

The rest looks like it should work :slight_smile:

I solved the problem. All I did was create a Boolean variable and set it to false, then if my first if statement equaled “brick 3” , I set the boolean variable to true inside the block. then in the if statement I couldn’t get to work; I set the statement to if the variable was true then do the rest of the statement. If that makes any sense to any one. lol