Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Doneyes · Aug 26, 2012 at 12:32 PM · ifstatement

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?

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Piflik · Aug 26, 2012 at 12:36 PM 0
Share

What are you trying to do?

avatar image Scribe · Aug 26, 2012 at 01:57 PM 0
Share

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

avatar image Piflik · Aug 26, 2012 at 02:03 PM 0
Share

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++;
 }
avatar image Doneyes · Aug 26, 2012 at 02:33 PM 0
Share

I added a boolean and solved my own problem. I just woke up when I made that and wasn't thinking well.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Doneyes · Aug 26, 2012 at 02:23 PM 0
Share

Okay well if I were to do that then it wouldn't add 1 to RoundCount every time Team1 adds a point.

avatar image Dasherz · Aug 26, 2012 at 02:26 PM 0
Share

Cant you just make redcount += 1 everytime $$anonymous$$m gets 1 added to it in the same section

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges