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 notgnilgum · Aug 11, 2019 at 05:18 PM · collidertriggerclosestcontactnearest

Find nearest contact point inside trigger

I have a sphere collider trigger and i need to find the closest contact point on various other colliders.

  • I've tried using "ClosestPointOnBounds" but have read here that the reason this isn't working is because i am dealing with rotated objects, and this method is "Axis Aligned", so this is a no go, unless someone knows a way to translate the axis aligned results into something meaningful?

  • I also can't simply raycast towards the origin of the "other" collider, as I'm dealing with large and variously shaped colliders, and I do need the closest point, so this will often give an unacceptable result for my purposes.

  • And I can't use the method suggested here of finding the nearest vertex as im not only dealing with mesh colliders, but spheres, boxes, etc.

  • I don't think i can simply use a kinematic rigidbody and normal collision detection, because I have to avoid my trigger sphere having any effect on the objects im colliding with.

Desperate at this point, so if anyone has a solution you will forever have my adoration.

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
Best Answer

Answer by notgnilgum · Aug 12, 2019 at 07:12 PM

Solved for those stumbling across this in the future:

Use "ClosestPoint" not "ClosestPointOnBounds" and make sure "convex" is ticked on all your mesh colliders!

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 imaginationrabbit · Aug 11, 2019 at 10:51 PM

Have you tried using ClosestPoint? link text You can use it to get the closest point from your trigger collider to the other collider then use the point it gives you with the trigger collider and ClosestPoint and that will give you the point of contact between the two.

You could also use the collider size/radius to fire a Ray in the direction of the other collider and use Ray.GetPoint link text

For the distance to use on GetPoint- you can use the position GetClosestPoint gives you- just some ideas-

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 notgnilgum · Aug 12, 2019 at 06:26 AM 0
Share

I tried closest point but it was giving me an error message about not working with most collider types, and I assume it has the same axis aligned problem as closest point on bounds? Though if I'm just being dumb I'd love to be corrected. And again, I can't just ray cast towards the other collider as the origin will often be nowhere near the closest point in my case.

avatar image notgnilgum · Aug 12, 2019 at 07:11 PM 0
Share

After some fiddling, there is a tick box "convex" on the mesh collider which magically makes "ClosestPoint" work perfectly, so you are actually on the money, thanks!

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

155 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

Related Questions

How to figure out the contact point of OnTriggerEnter? 1 Answer

Can't click gameobject when over another trigger? 1 Answer

Collision without physical behaviour. 1 Answer

How do I find the point of contact on a box collider? 1 Answer

OnTriggerEnter fails to activate 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