Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by AntJPGR · Oct 25, 2015 at 12:38 PM · invokerepeating

InvokeRepeating continuously running twice

Running InvokeRepeating for some reason runs my function twice (I see the timer take values of 2, 4, 6, 8, and from the results i get it seems that my whole function gets called twice before printing out in Update

In start I call

 InvokeRepeating("MatchUpdate", 1, 1.0f);
 

which is:

 public void MatchUpdate()
     {
         test = timer;
         HPos = false;
         APos = false;
         HPS = HMor * 0.1f + HCoa * 0.2f + HDef * 0.2f + HMid * 0.5f;
         APS = AMor * 0.1f + ACoa * 0.2f + ADef * 0.2f + AMid * 0.5f;
         Possession = HPS / (HPS + APS) + Random.Range(-5, 5);
         BPos = Random.Range(-5, 5);
         if (BPos <= Possession)
             HPos = true;
         else
             APos = true;
 
         HPass = 0.25f * HCoa + 0.55f * HMid + 0.1f * Random.Range(0, 100) + 0.1f * HMor;
         APass = 0.25f * ACoa + 0.55f * AMid + 0.1f * Random.Range(0, 100) + 0.1f * AMor;
         HDefend = 0.3f * HCoa + 0.4f * HMid + 0.25f * HDef + 0.05f * Random.Range(0, 100);
         ADefend = 0.3f * ACoa + 0.4f * AMid + 0.25f * ADef + 0.05f * Random.Range(0, 100);
 
         HShoot = 0.6f * HAtk + 0.1f * HMor + 0.3f * Random.Range(0, 100);
         AShoot = 0.6f * AAtk + 0.1f * AMor + 0.3f * Random.Range(0, 100);
         HBlock = 0.7f * HDef + 0.2f * HCoa + 0.1f * HMor;
         ABlock = 0.7f * ADef + 0.2f * ACoa + 0.1f * AMor;
 
         if (HPos)
         {
             StatHPos++;
             Pass =  HPass - ADefend;
             if (Pass <0)
                 Pass = 0;
             if ((Pass + 10)  >= Random.Range (0,100))
             {
                 StatHShoot++;
                 if (HShoot - ABlock >= 0)
                 {
                     StatHGoals++;
                 }
             }
         }
         else
         {
             StatAPos++;
             Pass =  APass - HDefend;
             if (Pass <0)
                 Pass = 0;
             if ((Pass + 10)  >= Random.Range (0,100))
             {
                 StatAShoot++;
                 if (AShoot - HBlock >= 0)
                 {
                     StatAGoals++;
                 }
             }
         }
         timer++;
     }

And I print out stats/results via another script, which get printed after every 2 calls of MatchUpdate. (Also I used the public variable "test" to monitor timer, and in the Inspector it still looks like it's getting called twice every time)

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 OctoMan · Oct 25, 2015 at 12:43 PM 0
Share

Tried to place a Debug.Log("i'm running"); into ? Check the Console how often it fires.

avatar image AntJPGR OctoMan · Oct 25, 2015 at 12:53 PM 0
Share

It prints 2 of them every second :/

avatar image OctoMan AntJPGR · Oct 25, 2015 at 12:57 PM 0
Share

Are you sure you only call it from one gameobject in the scene?

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

31 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

SNAKE - How to change InvokeRepeating rate? 0 Answers

how can i increese the repete rate in invoke repeting after some time 1 Answer

Invoke () Working like InvokeRepeating () 2 Answers

Invoke repeating wont repeat 1 Answer

Optimization: how to do a checking less often than within an Update 2 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