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 wlad_s · Feb 07, 2011 at 03:29 PM · speedinvokeinvokerepeatingrepeating

Is it possible to change Invoke Repeating rate on the fly?

Hi,

I have this code, it's pretty self-explanatory:

InvokeRepeating( "InstantiatePlatform", 1 , 6/globalSpeed );

function InstantiatePlatform () {

Instantiate (prefab, Vector3(spawnPoint.position.x, 0, 0), Quaternion.identity);

globalSpeed +=1;

}

Unfortunately, the rate of repeating the function doesn't change. It only takes the first value and continues to instantiate objects at that rate.

When I think about it, it's logical since InvokeRepeating doesn't update, but is there a way to change speed or should I use another method?

Thanx

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

3 Replies

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

Answer by Mike 3 · Feb 07, 2011 at 03:31 PM

Check the answer I posted here:

http://answers.unity3d.com/questions/15941/random-range-spawntime/15943#15943

Comment
Add comment · Show 1 · 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 schwertfisch · Mar 07, 2012 at 04:36 PM 1
Share

Can somebody re-answer this? The link cannot be found at the moment.

avatar image
2

Answer by Kiloblargh · Mar 07, 2012 at 05:44 PM

Since in your case the variable globalSpeed is being set by InstantiatePlatform every time it runs, don't use InvokeRepeating. Just use Invoke. Then have the function Invoke itself again at the end in (globalSpeed seconds).

If something somewhere else were changing the value of globalSpeed, you could check in InstantiatePlatform if globalSpeed has changed since the last time it ran, and if so, CancelInvoke("InstantiatePlatform") and InvokeRepeating again with the new speed.

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

Answer by rokyed · Jul 26, 2013 at 06:59 AM

Do not use Invoke alone ( it will instantiate your function every single time , wich meakes the whole process go slow , I started with a 78FPS ended with 4FPS only after 20000 times getting invoked . I also tested InvokeRepeating wich does not dumps all the data after and recycles it , so therefor you can do an invoke repeating with 0.01 delay , and use another variable to track the delay manually ... unfortunately not everything comes out of the box , most of it we need to make it.Good day!!

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

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

InvokeRepeating doesn't work 2 Answers

Increase speed every 5 seconds 1 Answer

Invoke Repeating Rate 1 Answer

2D Limit player speed 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