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
0
Question by Jonesy19 · Dec 29, 2016 at 04:06 PM · updatevelocityfixedupdatetime.deltatimeequal

Does FIxedUpdate get called every 0.02 seconds?

Hey everyone, I know there are a bunch of questions out there relating to fixedupdate vs update, but I can't seem to find the answer to my question. I have run unity on many different computers (PC's and Macs), and every time it shows fixedupdate as triggering every 0.02 seconds. Is this set, or could this be different?

I'm currently running code for slowing down movement by the following:

 velocity.x = velocity.x * 0.95

This is giving me exactly the desired effect when I use it in FixedUpdate, but I know that this code relies upon the fact that FixedUpdate gets called every 0.02 seconds...

so...

1) Does FixedUpdate get called avery 0.02 seconds? 2) If not, should I use Time.deltaTime or Time.fixedDeltaTime inside of FixedUpdate? 3) Is there a better way to do this, but still get the desired effect? I swear I'm having a brain fart.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by LK84 · Dec 29, 2016 at 04:20 PM

You can change your Fixed TimeStep under Edit-->Project Settings-->Time

Inside FixedUpdate using Time.fixedDeltaTime usually makes most sense. When you are doing any kind of physics calculations, FixedUpdate() should be your choice.

Comment
Add comment · Show 3 · 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 Jonesy19 · Dec 29, 2016 at 08:36 PM 0
Share

Thanks for your answer..That definitely helps...Just out of curiousity...Since Time.fixedDeltaTime in FixedUpdate and Time.deltaTime in Update are essentially the same thing (showing the time elapsed since the last time that function is called), why bother doing one vs the other? Sorry if my question seems obvious, I am just having a hard time wrapping my head around it!!

avatar image SF_Benjamin · Dec 22, 2018 at 05:45 PM 0
Share

Wrong. Time.fixedDeltaTime tells the theoretical time between fixed updates, not the elapsed time. Thats why you should user Time.deltaTime even in FixedUpdate.

avatar image Vega4Life SF_Benjamin · Dec 22, 2018 at 06:54 PM 0
Share

It doesn't matter what you use in FixedUpdate. Time.deltaTime will return the same as fixedDeltaTime when used in a FixedUpdate function.

avatar image
2

Answer by ScaniX · Dec 29, 2016 at 04:26 PM

This depends on two things:

  • Your setting for the physics frequency

  • The performance of the computer

The faster the computer is the more precisely it is called every N (1/physicsFPS) seconds. The contract however is that it is called a certain amount per second and it can even "pile up" (correct me if I'm wrong here) if there is too much to do in the fixed update or the computer is very slow.

You should use Time.fixedDeltaTime as Time.deltaTime will only contain the delta for the most recent frame.

Comment
Add comment · Show 5 · 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 Jonesy19 · Dec 29, 2016 at 08:36 PM 0
Share

Thank you very much for the response. I asked a followup question in the answer above and if you had an answer to that, I'd appreciate it too!

avatar image ScaniX Jonesy19 · Dec 29, 2016 at 08:41 PM 0
Share

Well, to say it in your words:

Time.fixedDeltaTime is the time since the last time the FixedUpdate() was called.

Time.deltaTime is the time since the last time the Update() was called.

The values differ as those two methods are not called in the same way. Update() is called for each frame which is usually as often as possible for the engine (probably limited by vsync or other explicit limits only) while FixedUpdate() tries to honor your frequency setting and is usually called once every N frames.

avatar image Jonesy19 ScaniX · Dec 29, 2016 at 08:43 PM 0
Share

Cool...but, theoretically, over one second of time, the object should move the same distance...I suppose the only difference, is that fixedUpdate will be more true to the final call, as update may be called slightly later or earlier (thus giving a slight variation in the final distance)...Thoughts?

Thanks...

Show more comments

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

65 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Physics after build feel different vs In-Editor (Time.deltaTime) 1 Answer

Physics using Time.deltaTime? 1 Answer

Using Time.deltaTime but acceleration is still tied to framerate 1 Answer

Only Disable One Update on a Script 1 Answer

Score, FixedUpdate and Update 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