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 Feref2 · Dec 13, 2018 at 06:24 AM · physicscollision detectiondistanceclosest

How to get an accurate collision distance (get closest points on one axis)?

So for my own reasons am making a collision detection system; but am struggling a little bit. Am not interested in angular acceleration and complicated stuff. I just want to get how much distance is left until collision. So I thought getting the closest points (the red ones) and then casting rays would be enough, but then I realized this: alt text

The closest points may not be aligned on the x axis, which leads to different problems. The red point on the rigidbody (the tetris figure) is not at the vertical edge. I Have drawn the brown lines where they should start and end. In this case are the limits of the bounding box, but it may not be that always. Besides that, in the first diagram the blue line is the shortest distance, not the brown. Then instead cast the ray from the red point on the other collider in the opposite direction? No. That doesn´t work either. As shown in the second diagram, that distance may actually be longer. Which would be the best approach to this? I need to get that information before the collision is done.

Edit: I have thought and realized that this problem is caused by the fact that the closest point may be above. Not just like this, but even above the rigidbody. Is there a way of getting the closest points, but aligned on one axis?

captura-de-pantalla-37.png (140.6 kB)
Comment
Add comment · Show 4
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 hexagonius · Dec 13, 2018 at 06:45 AM 0
Share

since tetro$$anonymous$$os consist of 4 squares each, you could just do a sweep test as far as the next move would go for all 4 locations and let the physix engine provide you the relevant collision points. then you can compare distances of x and y and the closest of both is the one.

avatar image Feref2 hexagonius · Dec 13, 2018 at 08:26 PM 0
Share

Thanks for your answer. I have searched and there´s litte information about sweep tests, but what I understand is that is like casting rays or shapes along the bounding box. So if it´s the x axis, it casts rays along the heigth to the left/ right and gets the closest collision. (Please correct me if am wrong). Besides from that, the tetro$$anonymous$$o was just an example. This is mainly for characters and rigidbodies with irregular forms. How would affect the sweep test in this situation?

avatar image hexagonius Feref2 · Dec 13, 2018 at 09:20 PM 0
Share

if it's getting more complicated than this and even as complicated as a whole character pose you should probably hire at NVidia Physics $$anonymous$$m, because then you're really good at this.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

165 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 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

Is there a limit on the distance of raycast? 2 Answers

How do I solve the Box Collider (3D) Edge / Corner Collisions problem? 5 Answers

How to get the center of a CapsuleCast or SphereCast on collision 1 Answer

Detect if a non-trigger collider is inside another collider 1 Answer

Can I implement basic physics on cubes without writing code? 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