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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Corund · Feb 17, 2014 at 12:18 PM · c#beginnerdocumentation

Where i can find detailed description of Unity C# funtions?

Hi all!

I came across a 2D video tutorial and there was a string: Physics2D.OverlapCircle() Where i can find what type of value will return OverlapCircle? Is it bool, float or may be object? In reference OverlapCircle is a Collider2D and this does not answer my question. Declaration of the OverlapCircle does not help me either and it is too complicated for my C# level. From the script of video tutorial it is obvious that OverlapCircle will return Bool value. But how can i find out this myself with the only help of Unity documentation?

Comment
Add comment · Show 1
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 Nicolaj Schweitz · Feb 17, 2014 at 12:22 PM 0
Share

Which video tutorial are you referring to?

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by wibble82 · Feb 17, 2014 at 12:29 PM

Hi there

In the docs: http://docs.unity3d.com/Documentation/ScriptReference/Physics2D.OverlapCircle.html

It shows overlapcircle returns a Collider2D, with a little bit of extra info in the text:

If more than one collider falls within the circle then the one returned will be the one with the lowest Z coordinate value. Null is returned if there are no colliders in the circle

So it'll return null if there's no overlap, or the collider with the lowest z coordinate if there is one. From the collider you can do mycollider.gameobject to get the game object that it is part of, and from there you can access all its other parts, including the transform if you want info about its parent etc.

In other words, if you want to use it, the code would be something like:

 //do the overlap test
 Collider2d coll = Physics.OverlapCircle(circle_pos, circle_rad);
 
 //check if we hit anything
 if(coll != null)
 {
     //we hit something, so get the game object
     GameObject collided_object = coll.gameObject;
 
     //...do stuff with it here!...
 }

If you check the docs a bit deeper you'll also see you can specify a layer mask, minimum depth and maximum depth to filter objects, and also use OverlapCircleAll to get a list of overlapping objects, rather than just the one with the smallest z coordinate.

-Chris

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

21 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

Related Questions

Multiple Cars not working 1 Answer

Refin' another script in relation to speed, and not tacking from using the Update? 1 Answer

Distribute terrain in zones 3 Answers

Where i can find detailed description of Unity C# function? 2 Answers

Detect OnMouseEnter/Exit/Down on childrens 0 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