Or If statements
Can you write an if statement, so that you say (in pseudo-code)
if(someRandomVariable == true OR somethingElse == true OR insaneRageMode == true){
Instantiate (pineapples, transform.position, transform.rotation);
}
And replace the "OR"s with some clever coding.
Comment
Best Answer
Answer by · May 30, 2011 at 04:44 PM
The symbol for OR is '`||`'
For example:
if( someRandomVariable == true || somethingElse == true || insaneRageMode == true )
// do stuff
Also, the symbol for AND is '`&&`'.
And there's no need to compare a boolean variable to true:
if (varBoolean)
does exactly the same as
if (varBoolean==true)
but looks better. There's no need to compare to false, too:
if (!varBoolean)
does the same as
if (varBoolean==false)
because ! is the NOT operator