I feel stupid.
What's wrong with this code:
It doesn't work, just writes Invalid team value to the log every time I hit play, no matter what the value of whichTeam is. I am confused. Seems to work if I change the
Easy to work around, but I just want to know, what's wrong with this? Or is Unity incapable of handling that?
asked Feb 18 '11 at 04:05 AM
Your code makes no sense, it'll enter the if statement for whatever value of whichTeam.
if whichTeam is equal to 1 then whichTeam != 2 therefore enters if statement
if whichTeam is equal to 2 then whichTeam != 1 therefore enters if statement
if whichTeam is equal to another value then whichTeam != 1 && whichTeam != 2 (both statements true) therefore enters if statement
Every case enters if statement.
If you want it to only enter the statement when whichteam doesn't equal 1 or 2, then you want.
What are the possible values which team can be? If it's 1 or 2 then it will always go into there because the OR operator. If which team is equal to 1 the second condition will let it pass as true and vice versa.
answered Feb 18 '11 at 04:11 AM