• 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 /
  • Help Room /
avatar image
0
Question by OttoClausen · May 21, 2016 at 04:31 PM · rigidbody2dphysics2dplatformlinecastinterpolate

Physics2D.Linecast unreliable with Rigidbody2D interpolation? What to do

Hello I am creating a platform game and I am using Physics2D.Linecast to detect whether my character is on the ground and thereby able to jump. I am currently trying to implement platforms that fall down when you land on them. My problem is that sometimes when the character lands on one of the platforms I can see that the onGround bool is false. T$$anonymous$$s confuses me a lot and I tried to use Debug.Drawline to draw the same line that Physics2D.Linecast is using and when I get those frames where onGround is false I can see that the line is in fact overlapping the collider on the platform and the onGround variable should therefore be true.

Both my character and the falling platform have rigidBody2D components attached to them with the interpolation setting turned on. I tried to test it without interpolation and it seems to work but it looks jittery and horrible. I am looking for some kind of explanation as to why t$$anonymous$$s is happening and if anyone can come up with a way or some tip on how to make the Linecasting reliable it would be awesome. Thank you 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

1 Reply

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

Answer by MelvMay · May 23, 2016 at 07:21 AM

The physics queries are 'reliable'. It seems that you don't understand what Interpolation actually is.

The physics system movement is based upon your fixed-update and therefore moves the physics bodies around in coarser steps and not per-frame. Interpolation (not extrapolation) moves the Transform-only per-frame from the last body position to the current body position to give smoother movement for t$$anonymous$$ngs that render/depend on the Transform such as sprites etc. The physics body isn't affected by interpolation, it's the basis for the Transform updates only.

When you perform casts (etc), you are performing it against the body/collider positions and not against the Transform/GameObject/Sprite positions i.e. it has not$$anonymous$$ng to do with the Transform position. You can output t$$anonymous$$s if you look at the Rigidbody2D.position as compared to the Transform.position.

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 OttoClausen · May 23, 2016 at 11:27 AM 0
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

54 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

Related Questions

how to clamp( set max value) the velocity of a 2d rigidbody? 1 Answer

Platforming character is jumping higher while walking 0 Answers

Rigidbody2D.Cast() against mutiple colliders with a single Rigidbody2D 0 Answers

Physics 2D with tile collider corner problem 2 Answers

RigidBody.MovePosition won't stop even after reaching the destination 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