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
1
Question by Instinct · Nov 11, 2014 at 03:38 PM · if-statementsint

(C#) Figure out when a number (int) reaches every tens

Hello all, I am sorry for my poorly formulated topic.

Anyhow, I am trying to figure out how to "calculate" when a number hits 10, 20, 30, 40 etc. And it must be a simpler and more clever way to do this instead of saying:

 If (ComboMultiplier == 10){
 DoSomething1();
 }
 
 If (ComboMultiplier == 20){
 DoSomething2();
 }
 
 If (ComboMultiplier == 30){
 DoSomething3();
 }
 
 
 

The ComboMultiplier adds a number (combomultiplier += 1) when you do a successful attack on a enemy. And I want the combo number flash on the screen every 10th successful attacks in a row. (I have a working code for the combomultiplier, so don't you worry about that :) )

In advance, thanks!
Simon

Comment
Add comment · Show 1
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 Marvin_Wack · May 06, 2021 at 05:21 PM 0
Share

A bit late but how did you do the flash of the combo-number? I'm still looking for a good way to do it ^^

1 Reply

· Add your reply
  • Sort: 
avatar image
7
Best Answer

Answer by Tanshaydar · Nov 11, 2014 at 03:45 PM

Instead of doing it, you can do it this way:

 if(ComboMultiplier % 10 == 0){
      // This means that ComboMultiplier is multiplier of 10 (10, 60, 250, 125360)...
 }

if you'd like to know how many 10s there are, it's this way:

 int multiplier = ComboMultiplier / 10;
 // This will give you how many 10s there are ( 10 -> 1, 60 -> 6, 250 -> 25, 125360 -> 12536)

So, you can do this:

 if (ComboMultiplier % 10 == 0){
      switch( ComboMultiplier / 10) {
      case 1:
           DoSomething1();
           break;
      case 2:
           DoSomething2();
           break;
      case 3:
           DoSomething3();
           break;
      }
 }

Hope this helps :)

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 Instinct · Nov 11, 2014 at 04:56 PM 0
Share

Wow this seems like what I was looking for, will test it! Thanks for the quick reply sir!

avatar image Instinct · Nov 11, 2014 at 05:04 PM 1
Share

Worked! Upvoted and accepted answer as correct! :)

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Generating a random number and detecting what number it is 4 Answers

How to see if an int ends with a certain number 1 Answer

Checking to see if a loaded level is equal to a member of an integer array 1 Answer

Pass a function(float) as variable 2 Answers

Monodevelop is expecting int from my float array 3 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