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
0
Question by DevMerlin · Feb 27, 2013 at 08:40 PM · collidertagoverlapsphere

OverlapSphere seems to detect everything and ignores tags. How can I fix this?

I'm trying to set up a per-unit sensor in order to detect when friendly units get near for the unit to follow. However, at the moment I'm using an OverLapSphere. It's completely ignoring my "Obj.tag" and detecting everything, and not making any sense as to why it should for me.

         targetArray = Physics.OverlapSphere(transform.position, 1.5f, mask.value);
             
         foreach(Collider obj in targetArray)
         {
             if (obj.tag == "ConvoyMember" || obj.tag == "Player")
             {
                 followTarget = obj.gameObject;
                 
                 CancelInvoke("changeDirection");
                 transform.parent = null;                
                 behaviourMode = behaviour.follow;
                 
                 break;
             }
         }
         

One possibility is that the object sending out the OverlapSphere is also a "ConvoyMember", but it shouldn't be detecting itself. Is there any way to stop that from occuring?

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
0

Answer by Eric5h5 · Feb 27, 2013 at 08:47 PM

OverlapSphere has no ability at all to filter by tags; it can only filter by layer. It returns an array of all objects in a radius, so what you do with tags after that is up to you and doesn't have anything to do with OverlapSphere. Offhand I don't see anything obviously wrong in the following code, but it depends on other code so it's hard to say, and is kind of a different question anyway.

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 DevMerlin · Feb 27, 2013 at 08:55 PM 0
Share

Hmm. This could be a $$anonymous$$or problem. I wanted to use OverlapSphere to detect potential follow targets, ins$$anonymous$$d of using an array and proximity. Each object that is casting a OverlapSphere needs to be a "Convoy$$anonymous$$ember". Are there other alternatives?

avatar image Eric5h5 · Feb 27, 2013 at 09:02 PM 0
Share

I don't know that you need an alternative, you just need to fix your tag code if necessary. $$anonymous$$y point is that it's nothing to do with OverlapSphere, which merely returns an array based on the input you gave it. Once you have the array, where it came from is irrelevant, and you work with it like any other array.

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

10 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

Related Questions

Use trigger with player but have a collider with everything else? 3 Answers

What's wrong with OnCollisionEnter? 2 Answers

CompareTag being ignored? 1 Answer

Area of effect 1 Answer

handling collision with two objects of the same tag 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