Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by Orion 1 · Feb 04, 2011 at 11:11 AM · collidertriggerontriggerstayzone

Determine that an object is -within- a trigger

Let's say I have an oddly shaped MeshCollider set up as a trigger, and I want to check if a certain object is within this trigger.

Unfortunately, OnTriggerStay is only called if the object touched the boundaries of the trigger, and I found OnTriggerEnter and OnTriggerExit rather unreliable to tell which objects went in and which went out.

Any bright ideas?

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 tool55 · Feb 04, 2011 at 02:21 PM 0
Share

When you say OnTriggerEnter is unreliable, what do you mean? That it's not detecting objects or that you don't know how to access that info?

avatar image Senhor de todo o Mal · Feb 04, 2011 at 02:36 PM 0
Share

How oddly shaped is the $$anonymous$$eshCollider? If you are having problems with the OnTrigger functions I would suppose it's a non-convex shape. Can you give us more information on this?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bampf · Feb 04, 2011 at 12:18 PM

Haven't tried this, but the following algorithm from computational geometry should work:

http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html#Polyhedron

Basically, you fire a ray from a point, and if that ray hits an odd number of faces of the mesh, then you are inside. Use RaycastAll to get back all the hits, not just the first one, and use the new raycast layers feature to avoid hitting other meshes.

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

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

No one has followed this question yet.

Related Questions

OnTrigger event when colliders are already touching eachother 1 Answer

Combining Triggers 1 Answer

Trigger animation going crazy 3 Answers

How to use OnTriggerEnter with multiple triggered objects? 1 Answer

Work around for onTriggerStay? 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