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 /
avatar image
1
Question by Neran28 · Nov 07, 2016 at 10:41 PM · fpsupdate functionspeed issues

Update() intervals and fps

Hello, i know that fixedUpdate() is called every 0.02 seconds and that update() calls are not consistent. FixedUpdate() is recommended to be used with physics calculations and update() for everything else, right?

The documentation states that update is called every frame. So if my fps are lets say 70 its called 70 times per second. If my fps are 200 its called 200 times per second. But wouldnt this result in a faster/slower game when my fps changes if calculations are done in update? Also if i want to track anything that is time dependent or detects inputs this would also be messed up. Like playing old games on emulator without capping framerate.

Comment
Add comment · Show 4
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 TreyH · Nov 08, 2016 at 04:35 AM 0
Share

FixedUpdate time is controlled by you via the Editor.

avatar image aditya007 · Nov 08, 2016 at 05:44 AM 2
Share

You can use Time.deltaTime if you want to be frame independent. And, tracking something that is time dependent can also be done by Time.deltaTime without messing anything up.

avatar image Neran28 aditya007 · Nov 09, 2016 at 04:50 PM 1
Share

thanks for your answer aditya007. i want to clarify this with an example, to make sure that i understood that right: lets say i simply want to move my character with inputs (w,a,s,d) in Update().

if i just move my character with transform.Translate(movementvector) the movement would be different on different machines (fps dependent), right? ins$$anonymous$$d i should use transform.Translate(movementvector * Time.deltaTime)?

I have looked up this video about Time.deltaTime https://unity3d.com/de/learn/tutorials/topics/scripting/delta-time

For me this video is confusing because it looks like the slowdowns/speedups only occur in between a time interval but at the end of this time interval both squares are at the same position. Also the tutor says that Time.deltaTime is used to make the movement smooth here.

But wouldnt this then mean that Update() is already executing a set amount of times per second with the single frames being not consistent within this second? However the documentation states that its called every frame. What i mean is that the red square without Time.deltaTime should have moved a lot faster overall than the other one, if Update() is executed once per frame.

Im now more confused than before...

Edit: i managed to unlock my framerate so i was able to test this in the editor. for the movement i simply added my vector to transform.position. update() is called indeed every frame. high framerates (over 100) = extremely fast movement, low framerates = slow movement. Time.deltaTime fixed this. i think i just misunderstood the example with the squares in the video.

avatar image Bunny83 Neran28 · Nov 09, 2016 at 06:29 PM 0
Share

Yes you misunderstood the example in the video ^^. The first part of the video focuses on the tiny flucuations that the frame time might have and deltaTime "smoothes" those (at least visually). Your case, where you have different framerates, is handled at the end of the video where they explain that deltaTime makes things dependent on time rather than the framerate.

deltaTime is simply the time between the last and the current frame. So at a framerate of 60 fps deltaTime is about 1/60 (~0.0166). If you add up deltaTime each frame you will get a value of about "1.0" after one second since "60" times "1/60" is "1". deltaTime will be updated every frame depending on how long the last frame took so on average you get a constant time based movement / increment,

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Android/Desktop Sync Movement with Time.deltaTime 0 Answers

waitforseconds in update good for perfomance ? 2 Answers

How to shoot RayCast in center of screen? 1 Answer

Temporarily disable audio? 1 Answer

Fps Ammo pickup problem(programming noob) 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