- Home /
Boolean Errors
Error:
Expressions in statements must only be executed for their side-effects.
Script:
var pressed : boolean = false;
function OnMouseDown () {
audio.Play();
if (pressed == true) {
Application.Quit();
}
}
function OnMouseUp () {
pressed == true;
renderer.material.color = Color.red;
audio.Play();
}
Question:
Why?
EDIT:
I DID Google it but I didn't get an answer I could understand. Thanks for anyone who can help.
Answer by SP0KK0 · Feb 16, 2013 at 08:40 PM
Line 15 of your script should be
pressed = true;
You only use 1 equals sign when you are assigning a value to a variable
Thanks both of you, sorry flaviusxvii, SP0$$anonymous$$$$anonymous$$0 got it first.
Yeah, taking the time to type out an explanation usually makes my answers late. :)
Answer by flaviusxvii · Feb 16, 2013 at 08:37 PM
function OnMouseUp () {
pressed == true; // THIS IS MEANINGLESS
renderer.material.color = Color.red;
audio.Play();
}
you meant to do pressed = true; A single '=' is the assignment operator. I stores the value 'true' in the variable 'pressed'. '==' is the equivalency operator. It compares 'pressed' and 'true' and returns the result.
Your answer
Follow this Question
Related Questions
JS Unity Boolean 'not possible to evoke an expression of type 'boolean'' 1 Answer
Codding Error(I need help)!!!!!!!!!!!!!!!!!!!!!!!! 1 Answer
Referencing external static variable with no success 2 Answers
Why am I getting this error repeatedly? 2 Answers
BCE0049 error with networking script 0 Answers