- Home /
Programming noob help
I am a very beginner with java. I am mmessed up with if and true/false. How to make this look correct? (That's not the whole script)
function Start(){
if (gotKey) = false);{
defaultRot = transform.eulerAngles;
openRot = new Vector3 (defaultRot.x, defaultRot.y + DoorOpenAngle, defaultRot.z);
Is your problem solved? If so please accept the right answer.
Answer by ExTheSea · May 14, 2013 at 04:46 PM
Look at this line:
if (gotKey) = false);{
You have a semicolon behind your if also there are some other weird things in ther. It should look like this:
if (gotKey == false){
Will that even compile? Since you have one closing bracket more than open brackets?
Oops i just came home from work and didn't even notice the other weird things in there. I edited my answer. Thanks for pointing it out OrangeLightning.
if(got$$anonymous$$ey){}
is a shorter way to do that. at the end of the day, an if statement just evaluates the contents of the parenthesis and deter$$anonymous$$es if everything adds up to true or false.
so, if you just feed the if statement a boolean (which is already true or false) then you don't even need to make a comparison
That's right but i used the "extended" version because it is closer to his version and it propably looks more clear to someone new to program$$anonymous$$g but yes:
if(got$$anonymous$$ey)[] is the same as if(got$$anonymous$$ey == true)[]
and
if(!got$$anonymous$$ey)[] is the same as if(got$$anonymous$$ey == false)[]