Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 TruffelsAndOranges · Jul 11, 2015 at 09:06 PM · frameratestutter

Application.targetFrameRate slows down FixedUpdate and physics simulation!

I set Application.targetFrameRate = 30 to try to remove some stuttering in my 2D game; however, when I did this, all physics simulation also is slowed down! The physics are running at about 0.5 normal speed too. This seems rather strange! I'm only using rigidbodies 2D and only setting their velocity, so it's not something stupid as me setting positions in Update().

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 starikcetin · Jul 11, 2015 at 10:07 PM 0
Share

Ok, what's the question you want us to answer?

avatar image TruffelsAndOranges · Jul 12, 2015 at 09:48 AM 0
Share

Shouldn't targetFrameRate just change update rate/FPS and not game/physics simulation rate?

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by TruffelsAndOranges · Jul 11, 2015 at 10:02 PM

It seems as if Time.time is slowed down by (60 / targetFrameRate)! Really weird! :S

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 starikcetin · Jul 12, 2015 at 10:48 AM

Ok. Frame rate means how many frames are called in a fixed time period (very very usually a second). If you change the frame rate your codes will be called more or less frequently. This is why we do physics in fixedUpdate instead of update, because frame rate in update changes constantly, (and actually this is why Time.deltaTime is there for.).

Similar to "Time.deltaTime", there is a "Time.fixedDeltaTime". If you want your codes to do same thing all the time, no matter if frame rate changes or not, you must duplicate you final variables and vectors that you use to do things in game by "Time.fixedDeltaTime".

Why? Let's think that we have a code like this:

     public float f = 0;
 
     void FakeUpdate()
     {
        f++;
     }

If we adjust our frame rate to 20, and if it's absolutely called 20 times in a second, we will have "f = 20" result at the end of a second.

Let's change the frame rate to 30... What happened? Same code, same things happen but it give the result "f = 30". Why? Because our code runs a constant code every frame not depending on frame rate.

Let's look at this code piece:

     public float f = 0;
     
     void FakeUpdate()
     {
        f += 1 * Time.deltaTime;
     }

If we set our frame rate to 20, 30, 40... we will always have "f = 1" result in the end. Why? Because we do this in every frame: f = f + (1 * (1/frameRate)) , and at the end our f equals this: f = 1 * (1/frameRate) * frameRate. frameRates neutralize themselves and we will have a constant "1" at the end. That means no matter what your frame rate is, you will have "f = 1" at the end.

Best wishes.

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 samifruit514 · Jul 06, 2018 at 12:36 PM

I dont understand. I have the same problem even if I multiply everything by deltaTime.

Can this be related to my timesteps settings? I have 0.01667 for fixed timestep and 0.01667 for max allowed.

If I set Application.targetFrameRate= 10, everything is slow motion.

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

23 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

Related Questions

What could cause a periodic "freeze" with no memory or cpu spike? 0 Answers

Updating slider.value causes major stutter in VideoPlayer 0 Answers

Physics stutter in windows build 0 Answers

Frame rate stutters regularly in Chrome + Flash 0 Answers

Game stuttering only in iPhoneX and above. Not a performance issue. 0 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