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 Tyler 2 · Dec 31, 2010 at 07:36 PM · invokerepeating

Pause InvokeRepeating?

Hello. Is there any way to pause InvokeRepeating for a few seconds and then have it continue again? So if a function is being called every 2 seconds, something happens, and it is not called for 4 seconds, and then it starts back up and is called every 2 seconds again. Thanks

Comment
Add comment
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

1 Reply

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

Answer by Jason B · Dec 31, 2010 at 07:41 PM

Just a thought, but could you just set your InvokeRepeating to use a variable for the time it takes for it to repeat, and then change the variable as you need to?

For instance, you declare a float called RepeatDelay or something, and then for your invocation, just do InvokeRepeating("TheThingToRepeat", RepeatDelay).

It wouldn't be strictly pausing, but if you set the repeat delay extremely high, you could essentially cause it to "pause" for a few seconds. Not sure how this would all work in practice, but at the moment I can't think of anything wrong with it.

Edit: Oh! Another idea I thought of. Place the entire function you're invoking inside of an if statement that checks if a simple switch is on, perhaps a boolean called InvocationIsPaused or whatever you like. That way it would still be invoked, but it wouldn't do anything if the boolean was false. Plus that way it would strictly keep on the same timing and not miss a beat when it unpauses.

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 Abdul91 · Feb 03, 2015 at 06:04 AM 0
Share

I know this comment is very - Very late, but what does using a variable for repatdelay do in this scenario where you have to pause the invokerepeat, not change its delay time (which can only be set once) ?

avatar image Ziplock9000 · Nov 08, 2018 at 12:11 PM 0
Share

None of these ideas answer the question, they don't pause the InvokeRepeating. The first one is completely wrong, the second one is a workaround for some situations but is not an answer.

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

1 Person is following this question.

avatar image

Related Questions

Invoke Repeating Rate 1 Answer

Invoke repeating limit? 1 Answer

Invoke.Repeating doesn't really "care" about repeat time? 1 Answer

InvokeRepeating affecting parts of script 1 Answer

Is it possible to change Invoke Repeating rate on the fly? 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