• 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 Selevan · Jun 23, 2013 at 05:51 PM · collisionphysicstagcheckoverlapsphere

OverlapSphere, check how many object with specific tag did it collide with..

Like in the topic. I want to cast a sphere, to check if there is one or more doors around my player character.

Any idea ?

Comment
Add comment · Show 3
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 Graham-Dunnett ♦♦ · Jun 23, 2013 at 05:52 PM 0
Share

You think 3 hours is ages??? For volunteer mods to work at the weekend?

avatar image Selevan · Jun 23, 2013 at 05:52 PM 0
Share

Well, sorry. Didnt know they're volunteer.

avatar image Selevan · Jun 24, 2013 at 09:13 AM 0
Share

Anyone has any idea ?

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer Wiki

Answer by Linus · Jun 24, 2013 at 09:51 AM

This is from a script of mine, basicly just a modification of the sample script at http://docs.unity3d.com/Documentation/ScriptReference/Physics.OverlapSphere.html

     var hitColliders = Physics.OverlapSphere(transform.position, 500.00);
     var resScript : residenceData;
     var numDoors : int = 0;
     
     for (var i = 0; i < hitColliders.Length; i++) {
         Debug.Log('City sphere: '+hitColliders[i].name);
         if(hitColliders[i].tag == 'door'){
             numDoors += 1;
             Debug.Log('Door detected '+hitColliders[i].name);
         }
         
         if(hitColliders[i].tag == 'residence'){
             Debug.Log('City Detected '+hitColliders[i].name);
             resScript = hitColliders[i].GetComponent(residenceData);
             thisCity.population += resScript.population; 
         }                                        
     }
 Debug.Log('Amount of doors '+numDoors.ToString());

 

http://docs.unity3d.com/Documentation/ScriptReference/Physics.OverlapSphere.html

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 Selevan · Jun 24, 2013 at 09:58 AM 0
Share

Big thx!!!

avatar image Linus · Jun 24, 2013 at 10:05 AM 0
Share

Your welcome

avatar image
0

Answer by shubammishra · Aug 29, 2018 at 05:19 AM

Hi, I am able to get the name of the objects which are there in the collider radius but wants to get the data of the objects which are there in the collider radius. for ex. every object has it's serial number and data. How I can get those things. Thanks

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

18 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

Related Questions

Physics.CheckSphere with tag 1 Answer

getting the radius/position of overlapsphere 2 Answers

Tiny tag changing and checking problem 2 Answers

overlapsphere to destroy NPCs on exit 1 Answer

What's wrong with OnCollisionEnter? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges