• 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 jtsmith1287 · Aug 30, 2014 at 10:05 PM · updatetimefixedupdateinvokerepeating

InvokeRepeating OR Update OR FIxedUpdate?

I'm basically t$$anonymous$$nking to avoid modifying every calculation with Time.deltaTime, could I just do an InvokeRepeating and haveit run at 30 or 60 fps (or whatever works) instead of putting time sensitive stuff in Update? ALternatively, w$$anonymous$$le UT recommends using FixedUpdate for physics, could/should I use FixedUpdate to handle every other time sensitive calculation as well?

Comment
Add comment · Show 2
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 Kiwasi · Aug 30, 2014 at 10:37 PM 1
Share
avatar image jtsmith1287 · Aug 31, 2014 at 02:32 AM 0
Share

2 Replies

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

Answer by BMayne · Aug 31, 2014 at 12:31 AM

Hey JTSmith,

Don't be afraid of your friend Time.deltatime. Computer are super fast and doing that very simple math will not in that slightest have an effect your framerate. Using Invoke repeating would have more overhead then using your own timer system.

One t$$anonymous$$ng that sucks about InvokeRepeating is that you have no control when it is really called (ie. [After/before/during] Update, [After/before/during] animations, [After/before/during] FixedUpdate). T$$anonymous$$s does not sound like an issue but you have you other classes that depending on the function being called before they update on the same frame you might be out of luck.

What I suggest is making a simple timer class that you can use over and over again to call your functions. If you know how to use Delegates t$$anonymous$$s is super easy to do.

Let me know if you have any other questions.

Regards,

Comment
Add comment · Show 4 · 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 BMayne · Aug 31, 2014 at 12:32 AM 0
Share
avatar image jtsmith1287 · Aug 31, 2014 at 02:34 AM 0
Share
avatar image BMayne · Aug 31, 2014 at 02:42 AM 1
Share
avatar image jtsmith1287 · Aug 31, 2014 at 02:55 AM 1
Share
avatar image
0

Answer by OboShape · Aug 31, 2014 at 12:11 AM

Hope im getting the gist of t$$anonymous$$s JTSmith,

time.deltatime can be used in update or fixed update. deltaTime is the time difference between calls be it fixedupdate or update.

as far as I understand InvokeRepeating() uses a time difference in seconds, so therefore using deltatime be$$anonymous$$nd the scenes based on your current target platform framerate to give you a call every x seconds.

certainly use fixedupdate for any physics movement etc, as update will not run in sequence with fixedupdate and you could get some shonky movement etc.

have a little look at the tutorial in the learn section, for a bit more info http://unity3d.com/learn/tutorials/modules/beginner/scripting/delta-time

im by no means any kind of expert but t$$anonymous$$s is just what i interpret it to mean, if i understand it wrong then someone please correct me please :)

dont want to lead you up the preverbial garden path.

DaZ

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

25 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

Related Questions

Fixed timestep... 1 Answer

Interpolation with jumping - Acting Weird. 1 Answer

Slow update best practice 0 Answers

How often does the internal physics calculation get called? 1 Answer

Is there an equivalent of Time.frameCount for physics updates? 1 Answer


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