• 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
1
Question by PeterJK · Feb 11, 2013 at 12:44 PM · gameobjectmeshintersection

Detecting if two meshes intersect, precisely

I'm trying to gather all GameObjects a specific object intersects with. At the moment I'm using a broad sweep:

 Collider[] colliders = Physics.OverlapSphere(latestObject.collider.bounds.center, latestObject.collider.bounds.extents.magnitude);

But as I understand it, this uses a bounding sphere around each object to test for overlap, and so it may not be very precise. I'd like to then check each returned object with a more precise approach. Is there an easy built in way to check one object against another more precisely? Or do I have to literally manually go into the meshes and do triangle<->triangle intersection tests?

Thanks for any help!

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

Answer by GerryM · Feb 11, 2013 at 01:29 PM

If your objects are convex and do not have more than 255 tris you can use the mesh collider to check for collision (intersection).

Comment
Add comment · Show 3 · 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 PeterJK · Feb 11, 2013 at 04:47 PM 0
Share

Thanks for the answer Gerry - unfortunately I cannot rely on my objects being convex.

I should note also that I don't need any information about the collision/overlap, except that it has happened...if that simplifies the problem.

I'm beginning to think I'll have to look at my own triangle-to-triangle intersection function? :/

avatar image Bunny83 · Feb 11, 2013 at 05:32 PM 0
Share

Yes you have to do it yourself. This might help ;)

avatar image PeterJK · Feb 11, 2013 at 05:45 PM 0
Share

Thanks, just wanted to make sure I wasn't reinventing any wheels.

Very useful link too - cheers Bunny83!

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

11 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

Related Questions

Calculating mesh over GameObject scale 1 Answer

Carving the ground similar to the game "where's my water?" 0 Answers

How to have different materials on one GameObject? 1 Answer

How to show 3000+ Trees(generator) without getting Memory overflow (no terrain generator) 0 Answers

Rendering objects without mesh intersections 3 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