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
1
Question by Mark aka Dark · Mar 14, 2014 at 03:26 PM · collidertagfinddetect

Find all objects within mesh collider

Hi all,

I'm trying to wrap my head around for days, but i can't figure it out.

Situation: I have a mesh collider (like a bar) and i set it as a trigger. Now i'm try to make a script that let the owner of the collider find all the objects with a tag "enemy" within that collider.

Because of the mesh collider i can't use Physics.OverlapSphere or a detection within a range. OnTriggerEnter won't work either, because it won't detect enemies allready in the collider when it starts.

Hope someone can help! Thanks Mark

Comment
Add comment · Show 10
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 CodeElemental · Mar 14, 2014 at 04:00 PM 0
Share

Why is it that OverlapSphere won't work ? Are the meshcolider and the objects it collides with in the same layer? Otherwise , you could assign them to a different layer and do a OverrlapSphere call for a specific layer$$anonymous$$ask.

avatar image whydoidoit · Mar 14, 2014 at 04:03 PM 0
Share

Are these other object also mesh colliders? 'Coz that's going to be an additional problem unless they are all convex. I think disabling/enabling the colliders after the objects are in place may well cause the OnTriggerEnter to be fired.

avatar image Mark aka Dark · Mar 14, 2014 at 04:04 PM 0
Share

They are on the same layer, but the mesh is no Sphere. If that doesn't matter, what is the radius variable for then?

avatar image whydoidoit · Mar 14, 2014 at 04:11 PM 0
Share

OverlapSphere only checks against the AABBs of the colliders anyway, you won't want to do that I'd bet.

avatar image Mark aka Dark · Mar 14, 2014 at 04:15 PM 0
Share

The other objects dont have mesh collider, so that's one problem less :-)

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by raybarrera · Mar 14, 2014 at 04:20 PM

You could try getting the collider's bounds, the using bounds.Contains to test for a point inside of it.

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 whydoidoit · Mar 14, 2014 at 04:22 PM 0
Share

That's an AABB again, which is fine, but it "sounds" like the OP needs a mesh collider for something.

avatar image raybarrera · Mar 14, 2014 at 04:25 PM 0
Share

I guess what threw me off was that he mentioned Physics.OverlapSphere, but now seeing your guys' exchange, I think I agree with "flickering" colliders is the way to go.

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

24 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

Related Questions

Collision flag entering a tagged object's collider 2 Answers

Getting Objects from CheckSphere 0 Answers

Find all objects inside box collider 4 Answers

RaycastHit collider not showing correct tags 1 Answer

Fog On and Off Script Help! 2 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