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
3
Question by htaunay · Jan 06, 2012 at 12:16 PM · performanceupdatesynchronizationfixedupdate

FixedUpdate performance doubts

A very helpful answer from user Duck (http://answers.unity3d.com/questions/10993/whats-the-difference-between-update-and-fixedupdat.html) finally made it crystal clear for me the difference between Update() and FixedUpdate(), however one doubt still came to mind: what happens if the code inside my FixedUpdate() takes longer than the actual Time.fixedDeltaTime? How can Unity guarantee that the FixedUpdate() will execute exactly after 0.02 seconds if it takes 0.05 seconds just to run? Does it stop the process and continue on the next step? Or does the Time.fixedDeltaTime lose credibility?

I also read (http://answers.unity3d.com/questions/31843/multiple-scripts-with-fixedupdate.html) that the less FixedUpdate() calls, the better. I curious to know how prejudicial to my performance this practice actually is (or is it even valid?). I current have more FixedUpdate() than the actual Update() calls since my project is supposed to envolve synchronous multiplayer, and time controlled steps are an excelente way of guaranteeing that every client will be experiencing the same simulation. But if the exceeded use of FixedUpdate() is in fact a deal breaker, I would like to know so I can change my strategy as soon as possible.

Any help is welcome, and thanks in advance!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by aldonaletto · Jan 06, 2012 at 04:49 PM

According to the explanation given in the Time Manager, the physics cycle runs at a "theoretically" fixed rate: before drawing each frame, Unity runs physics cycles and adds the fixed time to some internal clock variable until it reaches the actual time. If the last frame was rendered 60ms ago, for instance, 3 physics cycles will run one after another before the new frame goes to the screen. This may seem odd, but from the physics point of view it's ok, since physics uses its internal clock to calculate things, and it always walk Fixed Timestep seconds from one cycle to another (Einstein would love this relative clock!).
The Time Manager defines a Maximum Allowed Timestep that limits the physics cycles between frames. Its default value is 100mS, thus with the default 20mS Fixed Timestep you can have at most 5 physics cycles between frames. If your FixedUpdates are too heavy and take more than the specified Fixed Timestep, the physics will slow down, what will make the rigidbodies move slower than they should.

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
1

Answer by Toeofdoom · Jan 06, 2012 at 05:07 PM

It will "lose credibility" if it takes too long - this is one of the downsides to using fixed timesteps. It doesn't scale at all to faster or slower computers. Generally as you get to the borderline it will start skipping draw calls so it has enough time to keep the simulation running at 50 updates per second even if it only displays it at 20. I don't know if unity ensures a minimum framerate and slows down the simulation too, but if it does it's pretty much irrelevant because the game was unplayable already. So yeah, get some tests going on an old computer or netbook so you can get that baseline.

As far as I know the issue with fixedupdate calls slowing things down is not at all unique to fixedupdate - there's nothing special about it vs Update(). It just matters more than Start() because start is only called once. As the other question points out, you would need a huge number of them for it to cause a real difference.

As for the whole synchronised multiplayer thing, your simulations can differ for various reasons even if you use fixed update, if you rely on the simulations playing out identically you can run into problems - unity handles some related things, but without knowing about your project I can't really tell if it's relevant.

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 jpthek9 · May 31, 2015 at 06:34 AM 0
Share

A bit of false information here. FixedUpdate is the perfect Unity-main-thread-safe option for synchronous games that are actually synchronous. It's very flexible and as long as you set up the synchronous game how it should be set up, FixedUpdate will do wonders. Having every unit call its own FixedUpdate though... not such a good idea.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

So what's the deal with FixedUpdate? 2 Answers

how to achieve a LateFixedUpdate effect 5 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Eliminating input loss 1 Answer

Not sure if this should go in Update or FixedUpdate function 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