• 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
7
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 everyt$$anonymous$$ng 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 t$$anonymous$$s 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 t$$anonymous$$s being needed if your fixed timestep is low enough. So am I right in t$$anonymous$$nking it should be used in games where fixed timestep may be a little $$anonymous$$gher?

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
avatar image NoUJoe · Aug 09, 2014 at 12:05 AM 0
Share

3 Replies

· Add your reply
  • Sort: 
avatar image
29
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 $$anonymous$$gh 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 t$$anonymous$$s scenario, especially with a $$anonymous$$gh render frame rate, you're likely to see some artefacts w$$anonymous$$ch 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 t$$anonymous$$s is the "None" option. However $$anonymous$$gh 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 everyt$$anonymous$$ng 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 $$anonymous$$gh. Generally the t$$anonymous$$ngs on w$$anonymous$$ch you'll notice problems the most are physics objects w$$anonymous$$ch 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, w$$anonymous$$ch is why Unity's recommendation is to turn interpolation on for the player character, but not for anyt$$anonymous$$ng 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
avatar image ozamgal · May 25, 2016 at 11:24 PM 0
Share
avatar image
7

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 t$$anonymous$$n 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 t$$anonymous$$nk 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 t$$anonymous$$nk 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, w$$anonymous$$le 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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

28 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

Related Questions

Profiler mystery with Physics2d 0 Answers

Disable weight "inheritance" when using HingeJoint2D? 1 Answer

Platformer2D Player sticks to platform corners 0 Answers

How can I slow the velocity of my player without it affecting fall speed? 0 Answers

increasing knockback of a rigidbody as received damage increases (like super smash) 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