- Home /
How can I perform a += on an if statement?
Lets say both variables are already filled out.
if(Team1 += 1) {
RoundCount += 1;
}
how can I get something like this to work?
I having trouble finding a reason why you would need to do this. Can't you simply do:
RoundCount += 1;
the line after you have
Team1 += 1
?
also you can use
RoundCount++;
rather than
RoundCount += 1;
Scribe
I can think of something, but I don't know if this is what he wants to do...maybe he wants to see, if Team1 was incremented by one and in that case increase RoundCount...
if(Team1 - OldTeam1 == 1) {
RoundCount++;
}
I added a boolean and solved my own problem. I just woke up when I made that and wasn't thinking well.
Answer by Dasherz · Aug 26, 2012 at 01:57 PM
U can't say if team += 1 in that spot as that makes no sense. In the brackets u are checking if something = something. So if team += 1 doesn't make any logical sense. try team == 1
Redcount is fine.
Okay well if I were to do that then it wouldn't add 1 to RoundCount every time Team1 adds a point.
Cant you just make redcount += 1 everytime $$anonymous$$m gets 1 added to it in the same section
Your answer
![](https://koobas.hobune.stream/wayback/20220613080212im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do you say in between for an if statement? 2 Answers
some scripting help 2 Answers
Destorying despite IF Statement 1 Answer
Script Performance Questions 3 Answers
My backpack script doubt 0 Answers