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
0
Question by valis0000 · May 25, 2018 at 12:41 PM · cameralerpfixedupdatedeltatimemaths

Inversing fixed delta time

 void Awake()
 {
     initialFixedTime = Time.fixedDeltaTime;
 }

 void FixedUpdate()
 {
     Time.fixedDeltaTime = Time.timeScale * initialFixedTime;
     fixedTimeFactor = 0.01f / initialFixedTime;
     inverseFixedTimeFactor = 1 / fixedTimeFactor;
 
     camForward = Vector3.Lerp(camForward, targetForward, 0.05f * inverseFixedTimeFactor);
 }

This whole block of code is confusing.

  1. What is the point of setting Time.fixedDeltaTime ?

  2. What is the advantage over using Time.deltaTime?

  3. What is happening with all those factors?

  4. Testing it, it does give a smooth interpolation, but what is really happening here?

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 FlaSh-G · May 28, 2018 at 12:57 PM

1.

fixedDeltaTime is implicitly inverse scaled by timeScale, while being responsible for the rate at which FixedUpdate is called. This means that if some other code would create slow motion by setting timeScale to a lower value (than 1), FixedUpdate would be called less frequently. Multiplying fixedDeltaTime by timeScale would counter this effect, so you'd get the same amount of smoothness even in a slow motion situation. The downside is that FixedUpdate is useful for deterministic simulation, and changing its frequency according to a value that can be changed as easily as timeScale will easily break that. I wouldn't recommend this step without a selfmade FixedUpdate cycle that would take over deterministic simulation. I'd personally prefer using that cycle for the camera though, and not change the builtin FuxedUpdate rate at all.

2.

In this case, Setting this value will not just change it for some multiplications, but change the frequency of FixedUpdate event calls.

3.

The calculations are pretty... useless. inversedFixedTimeFactor is

 1 / (0.01f / initialFixedTime)

which can be shortened to

 100 * initialFixedTime

In the end, the value is used times 0.05, so the final value can be shortened again to

 5 * initialFixedTime

The 5 is nothing but a static speed factor that determines how fast the camera will move. Saving initialFixedTime is just a workaround to get a Time.fixedUnscaledDeltaTime, needed because fixedDeltaTime is changed by that one line.

4.

So all this does in the end is a rather useless calculation of the value 5, multiplied by a constant value, while it changes the frequency of FixedUpdate to happen at a constant rate even when doing slow motion, which I'd not recommend to do. At least not with the builtin FixedUpdate.

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

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

Related Questions

Physics + first person camera = jitter? 4 Answers

Lerp stopping/not working? 1 Answer

Camera movement performs different with different inputs 0 Answers

How to fix stuttering when a gameObject´s position should be at a exact place each frame? 1 Answer

Odd character dash discrepancies. Time.deltaTime? 2 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