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
1
Question by fabian-mkv · Apr 29, 2016 at 05:03 PM · updateserverfixedupdate

Reduce framerate for server

Scripts in my game code contain FixedUpdate() and Update() calls. For the server-side code, only FixedUpdate() is needed since Update() only handles player input or graphics.

To conserve CPU, is it safe to bring the Application.targetFrameRate down to 5 fps (or something very small) and still have FixedUpdate() called independently? Or are FixedUpdate() calls somehow dependent on Update(), such as perhaps "FixedUpdate is only called right before Update as many times as needed"?

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
2
Best Answer

Answer by fabian-mkv · Apr 29, 2016 at 08:37 PM

Since the documentation isn't particularly clear about FixedUpdate() and Update(), I played around with different settings to figure out what's going on. Here are the key takeaways:

1) Application.targetFrameRate will only take effect if V-Sync is disabled (Edit -> Project Settings -> Quality. In Inspector: Other -> V Sync Count -> "Don't Sync").

2) In Linux headless mode, Application.targetFrameRate takes effect without changing V-Sync (presumably since there is no V-Sync in headless mode)

3) FixedUpdate() gets only called immediately before Update() as many times as necessary. If Update() frame rate is higher than FixedUpdate() frame rate, then there may be Update() calls without being immediately preceded by a FixedUpdate() call. If Update() frame rate is lower than FixedUpdate() frame rate, then there may be multiple FixedUpdate() calls immediately before Update(). Either way, even if the actual time between FixedUpdate() calls may be 2ms (as read with Time.realtimeSinceStartup) instead of default 20ms (as defined by Fixed Time Step under Edit -> Project Settings -> Time), the Time.deltaTime in FixedUpdate() used for physics calculations is still the constant (e.g.: 20ms).

For purposes of running a headless server, not specifying Application.targetFrameRate uses the default value of -1. This means, do Update() calls as fast as possible. This causes unnecessarily high CPU usage since you don't need that many Update() calls. If you set Application.targetFrameRate to something like 5, then you will get around 10 FixedUpdate() calls every 200ms, which is also not good. The correct way is to set Application.targetFrameRate to the same as the FixedUpdate() framerate:

 Application.targetFrameRate = 1f / Time.fixedDeltaTime;

Hope this helps someone.

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 chadfranklin47 · Feb 04, 2020 at 05:13 AM 0
Share

Helped me, thanks a lot :)

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

57 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 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

How do I call a function when my slider is at max value? 0 Answers

2D Platformer Controller responsiveness issue 0 Answers

How to do Inputs in Update and AddForce in FixedUpdate, infinite jumps ? 0 Answers

Change Fixed Timestep? 1 Answer

Raycast2D in update? 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