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 question was closed Jan 25, 2014 at 09:27 AM by Nick4 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Nick4 · Jan 19, 2014 at 07:58 PM · colliderarraysoverlapsphere

How can I access collider's game objects?

 Collider [] collidedObjects = Physics.OverlapSphere(transform.position,0.54f);
 

I'm using this to return all colliders that's in that area. But I need to access their game objects. Any ideas?

Edit : Don't tell me to use SphereCast because that won't work in my case since I need isTriggers active on my game objects.

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 iwaldrop · Jan 19, 2014 at 08:03 PM 1
Share

You're mixing your ter$$anonymous$$ology quite a bit here.

A) SphereCast will only pick up colliders, so it would be totally redundant to perform one when you already have an array of colliders. B) GameObjects don't have an isTrigger flag, only colliders do.

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by YoungDeveloper · Jan 19, 2014 at 08:02 PM

Like this ?

 for(int i = 0; i < collidedObjects.Length; i++){
     collidedObjects[i].gameObject. ..
 }
Comment
Add comment · Show 5 · 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 Nick4 · Jan 19, 2014 at 08:10 PM 0
Share

Doesn't that return the game object that hits the collider?

avatar image iwaldrop · Jan 19, 2014 at 08:14 PM 0
Share

It returns the game object of the collider in the array at index i.

avatar image YoungDeveloper · Jan 19, 2014 at 08:14 PM 1
Share

It returns each coliders gameObject i believe, isn't that what you wanted? By the way, you can test it pretty easy what returns what you know

avatar image Nick4 · Jan 19, 2014 at 08:26 PM 0
Share

Sorry, I'm all confused here. So what does return hit object?

avatar image YoungDeveloper · Jan 19, 2014 at 08:33 PM 1
Share

What you mean by hit object ?

What you do here is, you save colliders in array, through collider you can access it's gameobject. Nothing complicated here.

Follow this Question

Answers Answers and Comments

20 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

Related Questions

Aura/AOE Problem 2 Answers

how to make physics.OverlapSphere check multiple colliders? 1 Answer

Random results with physics.OverlapSphere and AOE attacks 0 Answers

Collider Array showing up empty,No Colliders showing up in my array 0 Answers

OverlapSphere picking colliders that are not inside 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