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 J-Snake · Sep 24, 2011 at 07:38 PM · physicsupdatefixedtimestep

Interpolated Fixed Timestep

Hi, I need to know one thing to give unity a shot. I cannot implement an interpolated Fixed Timestep in unity to maintain silky smooth movement. So I would like to know how the same results can be achieved in unity. Can I just attach a physics-component to everything that moves and interacts with the environment and then turn on interpolation? (I want all of these physics things in fixedUpdate, of course, to maintain consistent game-mechanics)

If it is a valid way of doing it then I am likely sold;) However some examples use a variable step for something like jump-physics of the character. I am not a friend of it. It should be in FixedUpdate, that way you will have always exactly the same jump, on every system.

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

Answer by Bunny83 · Sep 25, 2011 at 11:34 AM

Of course that's why we have FixedUpdate.

Some might think that FixedUpdate is running at a fix frame-rate but it's just a fixed Update that ensures the function is called a certain amount of times per sec. This can be configured in Edit -> Project Settings -> Time -> Fixed Timestep.

Because the Unity scripting engine uses a single thread all callbacks from Unity (Update, FixedUpdate, OnCollisionEnter, ...) are done from the same thread and therefore are bound to the framerate. However FixedUpdate uses a clever trick:

FixedUpdate can be called several times a frame. Some examples:

 Fixed framerate : 60 fps
 Fixed timestep  : 0.01666
 --------------------------
 -case 1:
     Framerate    : 120fps
 >Update();
                // omitted
 >Update();
 >FixedUpdate();
 >Update();
                // omitted
 >Update();
 ...
 
 --------------------------
 -case 2:
     Framerate    : 20fps
 >Update();
 >FixedUpdate();
 >FixedUpdate();
 >FixedUpdate();
 >Update();
 >FixedUpdate();
 >FixedUpdate();
 >FixedUpdate();
 >Update();
 ...

That ensures that FixedUpdate is called a fix amount of time but not really at a fix rate. However it doesn't matter since your game only provides feedback if framerate-intervals.

Time.deltaTime usually returns the time-delta between the last and the current frame. If called in FixedUpdate it returns the fixed-timestep instead. Like mentioned here you should always use Time.deltaTime since it automatically returns the correct timestep.

However sometimes it's almost impossible to include the deltaTime in accelerated physics-calculations. You don't have to use deltaTime but in this case you shouldn't change the fixedtimestep, otherwise you will get a different result ;)

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 J-Snake · Sep 25, 2011 at 07:37 PM

Thank you for the answer. However I fear my concern is not answered. I know all these technicalities behind various game-loops and thank you for confirming that. I want to put everything in fixed update because I want to keep a consistent rule-set for everyone(my games have no performance issues), but the problem is interpolation. I know how to implement all that myself in a flexible framework that gives me access to its game-loop. But what is common practise to achieve that in unity? What I need is not deltaTime but the time "remaining time". You can look the part below "free the physics" to see what I mean. http://gafferongames.com/game-physics/fix-your-timestep/

Thanks for your time. I hope we will find a practicable way out.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

When does a rigbidbody updates position? 1 Answer

Multiple scripts with FixedUpdate() 1 Answer

How often does the internal physics calculation get called? 1 Answer

Making FixedUpdate fixed-timestep-independent 3 Answers

How to make code in FixedUpdate() independent from fixed timestep? 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