Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
6
Question by NoUJoe · Aug 08, 2014 at 10:20 PM · physicsphysics2dinterpolate

Physics. What is interpolate, extrapolate, discrete, continuous?

I've been playing around with physics over the past few days, 2D physics. I understand mostly everything but when it comes to the interpolation and collision modes, I'm confused a bit.

Ill start with interpolate / extrapolate. I understand how each one affects rigidbodies, I turned the fixed timestep up to 0.5 seconds and simply let a body fall. With no interpolation, it was very juttery, with interpolate, it was really smooth as if the fixed timestep was not at 0.5, but slows down as it approaches another collider. Extrapolate also produces juttery results. However when fixed timestep is at the default 0.02 or less, there is no noticeable difference between this modes. But then it's documented as saying to use interpolate on characters driven by physics to smooth them out. Yet I don't see this being needed if your fixed timestep is low enough. So am I right in thinking it should be used in games where fixed timestep may be a little higher?

As for collision detection mode, I really really really cannot see any difference at all. I have done a lot of testing to try and see a difference but cannot. People say that discrete collision can cause colliders to pass through each other but I cannot get that to happen at all. No matter how fast I make a rigidbody move into another, it never passes through, ever. Whats the deal here?

Comment
Add comment · Show 2
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 EHogger · Aug 08, 2014 at 11:47 PM 0
Share

Interpolate and extrapolate have a smoothing effect as you have seen. It just means that if you have frames being rendered in between physics steps, the position of the object will be guessed based on where it was previously (or where it will be if you use extrapolate).

avatar image NoUJoe · Aug 09, 2014 at 12:05 AM 0
Share

But surely that would mean that there would be frames where bodies would clip (on the non fixed update frames), but that doesnt seem to happen at all

3 Replies

· Add your reply
  • Sort: 
avatar image
27
Best Answer

Answer by gfoot · Aug 09, 2014 at 12:11 AM

Regarding interpolation and extrapolation, you're right, if the physics frame rate is high then you won't notice much difference. One time when you will particularly notice a difference is if you arrange for your camera to move at a fixed velocity in Update(), and move a rigidbody at a fixed velocity via the physics. In this scenario, especially with a high render frame rate, you're likely to see some artefacts which would go away if you enabled interpolation.

My understanding is as follows:

The physics moves in discrete steps, e.g. at t=0.0s, t=0.5s, t=1.0s, t=1.5s. Suppose Unity is rendering a frame at time t=1.2s. It needs to decide what object positions to use.

The first option is to just use the positions calculated for t=1.0s - I believe this is the "None" option. However high the render frame rate is, the object will only visually move when the physics ticks.

The next option is extrapolation. Bear in mind that Unity hasn't calculated the t=1.5s position yet, because right now t=1.2s. But it can see the object's state at t=1.0s, including its linear and angular velocities, and extrapolate by assuming the object will continue with those velocities. So the time sinse t=1.0s is 0.2s, and it adds 0.2 times these velocities on to the linear and angular positions, and renders that location.

The last option is interpolation. Instead of guessing where the object might go, instead I believe Unity delays everything by one physics timestep. So at time t=1.0s, it would actually render the objects at their positions from t=0.5s. But it still calculates the physics for t=1.0s, it just doesn't render those positions yet. Later, at t=1.2s, it can now interpolate 0.2/0.5 of the way between the object positions at t=0.5s and t=1.0s.

Interpolation generally gives the best result, but at the expense of adding latency to the view. Extrapolation kind of works but runs the risk of objects being rendered at odd positions, e.g. penetrating each other, as it can extrapolate through a collision that it hasn't detected yet.

Again, as you said, it's often unnecessary to turn on interpolation at all, unless you've turned your physics timestep up really high. Generally the things on which you'll notice problems the most are physics objects which are moving vaguely in sync with non-physics objects that are moved in Update() rather than FixedUpdate(). The most important case is a camera tracking the player character, which is why Unity's recommendation is to turn interpolation on for the player character, but not for anything else.

Comment
Add comment · Show 2 · 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 NoUJoe · Aug 09, 2014 at 07:35 AM 1
Share

Hey thanks for the answer. That all makes sense and I'm pretty sure you're spot on with interpolate being behind. I think it's always one frame behind. I ran a test... fixed timestep to 0.5, two rigidbodies, one with interpolate and with extrapolate. I pause before I play so it enters play mode paused. Then I hit next frame and the extrapolate body moves whilst the interpolate body stays still for 1 frame.

avatar image ozamgal · May 25, 2016 at 11:24 PM 0
Share

This answer is brilliant!! So explanatory... i have searched this info for long and now i found it! Thanks!

avatar image
5

Answer by terresquall · Aug 03, 2020 at 03:56 PM

I teach Unity certification classes, and I receive a lot of questions about Interpolation and the Collsion Detection properties, so I've written articles on them. Interpolation is mainly used to remove jitter in Rigidbody movements, and Collision Detection is used to prevent fast-moving objects from tunnelling through thin objects.

https://blog.terresquall.com/2020/08/unity-rigidbodys-interpolate-property/ https://blog.terresquall.com/2019/12/collision-detection-modes-in-unitys-rigidbody-component/

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
1

Answer by haikezhijian · Jun 02, 2016 at 09:54 AM

I agree gfoot's explanation, but i think the point about interpolation is not right. unity doesn't delay a physics timestep to render, i test interpolation, don't find delay render, so i think it is just based on previous frames to calculate Velocity and Acceleration. So interpolation is more accurate than extrapolation. Because extrapolation is based on current Velocity, while interpolation is based on current Velocity and Acceleration. In other words, extrapolation is fit for constant Velocity, interpolation is fit for constant Velocity and non-constant Velocity. Certainly, interpolation mode will cost more.

Comment
Add comment · Show 1 · 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 javster101 · Dec 06, 2016 at 07:19 PM 1
Share

By delaying by a physics timestep, think about it as the render is running as if it is a full physics timestep late. Therefore, the physics is not the one being delayed, its the render cycle running late. Clue's in the name. Extrapolation, by definition, is the process of estimating, beyond the original observation range, the value of a variable on the basis of its relationship with another variable.. Contrast this with interpolation, which is a method of constructing new data points within the range of a discrete set of known data points. This means that interpolation inherently requires 2 data points (in this case physics updates) to estimate between them, while extrapolation requires a point, but estimates after it and does not require a point after it. They are very different techniques. If they were similar, as you are saying, there would be absolutely no need for extrapolation, as most non-colliding objects are cheap to compute anyways.

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

27 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

Related Questions

2D physics settings for solid 2D objects with polygon collider 0 Answers

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

Slow down object about to collide 1 Answer

Need help with my movement script.. :( 1 Answer

Interpolation issue, some items not being interpolated correctly. 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