- Home /
Boolean Problem
I don't know if it's related to other lines and script is long, so i just copying the problem:
moveCombo = animation.IsPlaying("CharacterState.ComboA1");
Debug.Log("moveCombo " + moveCombo);
if(moveCombo);
Debug.Log("moveCombo " + moveCombo);
And it prints "moveCombo false" twice in the console as soon as i run the game. How could this happen? I want it to change to true when animation playing, but this is weird, never says true.
Answer by whydoidoit · Jan 20, 2013 at 02:42 PM
You have a ";" after your if! So the second debug line always shows.
Thanks, that solved. I never thought semicolon can do this.
I have a good friend who woke his wife up one night when he was having a nightmare. He sat straight up in bed and shouted "semicolon" - I guess he was drea$$anonymous$$g about a problem like this!
Answer by aldonaletto · Jan 20, 2013 at 02:45 PM
This if is dead: you killed it with a semicolon! Remove the semicolon:
if(moveCombo) // no semicolon here!
Debug.Log("moveCombo " + moveCombo);
You'd better to use curly braces in all if instructions to avoid confusion:
if(moveCombo){ // curly braces make things clearer!
Debug.Log("moveCombo " + moveCombo);
}