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
0
Question by FlintCLeaver · Oct 04, 2012 at 11:57 AM · optimizationframeratefixedupdatetime.deltatimeindependent

FixedUpdate and Time.deltaTime slowe

I am moving rigidbodies around with velocity.

Is simply using

 function FixedUpdate(){
 
 
 thisRigidbody.velocity.x = movement.x;
 
 }

enough to make the movement framerate INDEPENDENT. versus

 function FixedUpdate(){
 
 
 thisRigidbody.velocity.x = movement.x * Time.deltaTime;
 
 
 }

Which seems to slowdown my game.

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

Answer by Broheim · Oct 04, 2012 at 12:06 PM

The FixedUpdate already is framerate-independent. I suggest you try to learn the exact difference between Update() and FixedUpdate (). They correspond to Time.deltaTime and Time.fixedDeltaTime.

EDIT: like Kryptos pointed out, the Time.deltaTime inside a FixedUpate indeed does return the fixed timestep as mentioned in the documentation. I wasn't aware of that.

Comment
Add comment · Show 7 · 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 FlintCLeaver · Oct 04, 2012 at 12:14 PM 0
Share

thanks! I was just making sure and correcting some errors from earlier coding.

avatar image Kryptos · Oct 04, 2012 at 01:44 PM 0
Share

This answer is wrong. Inside FixedUpdate, Time.deltaTime is not framerate-dependent. It is (almost) the same as Time.fixedDeltaTime.

See documentation: Time.deltaTime

avatar image SarperS · Oct 04, 2012 at 01:49 PM 0
Share

FixedUpdate is not getting called every frame whereas Update does. Therefore there is no reason to use the deltaTime value in a FixedUpdate which is already time dependent.

avatar image Kryptos · Oct 04, 2012 at 01:55 PM 0
Share

@sarper. Nope this has nothing to do with that. Time.deltaTime DOES mean something inside FixedUpdate. But this does not make sense to use it for a velocity, unless movement represents an acceleration.

avatar image Owen-Reynolds · Oct 04, 2012 at 02:22 PM 0
Share

Yes, the answer is wrong. I just printed `Time.deltaTime` inside of Update/fixedUpdate. InFixed, it changes into exactly 0.02 (the value of `fixedDeltaTime.)

In other words, the code would be wrong for not using "fixed" in front of `deltaTime,` but Unity has your back, and the code works fine. The real error is not realizing velocity already has a secret `T.fDt` in the physics step.

Show more comments
avatar image
1

Answer by Kryptos · Oct 04, 2012 at 01:51 PM

It is slower with Time.deltaTime because this value is always lesser than 1.

In fact it does not make sense to set the velocity using Time.deltaTime since a velocity is already integrating the time. You need to use this value when you set a position using a value that is a velocity. This is basic middle school physics:

 *velocity* is a value which unit is in **m/s** <br>
 *time* is a value which unit is in **s** <br>
 *position* is a value which unit is in meters (m) <br>
 ----
 Therefore: <br>
 *position* &#61; *velocity* * *time* (m &#61; m/s * s) <br>

It would make sense if movement was an acceleration vector, but I don't think that it is the case here.

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 SarperS · Oct 04, 2012 at 02:11 PM 0
Share

Never$$anonymous$$d the previous comment, I thought FixedUpdate was getting called every fixed timestep, it seems it gets called every fixed framerate frame so it's not time dependent. You are correct, thank you!

avatar image FlintCLeaver · Oct 04, 2012 at 11:37 PM 0
Share

Thanks! SO I guess using velocity Time.deltaTime is not necessary! Thanks

avatar image Fattie · Oct 16, 2012 at 03:39 PM 0
Share

this is the answer

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

14 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

Related Questions

I do not understand Time.deltaTime 1 Answer

Framerate independent physics (FixedTimestep, FixedDeltaTime) 1 Answer

Locate cause of massive frame rate drop 0 Answers

Performance of game depends on computer's power option? 0 Answers

Animation of terrain causes drastic performance drop (fps) 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