Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 ArIaNFury008 · May 03, 2020 at 07:27 AM · find-gameobjectfindchild

Find All GameObject in Circle Area

i have problem with find gameobject in circle area i tried with Collider2D and tags but didnt work i have more 200 objects in sence and i just want show gameObject in Circle Area


using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class CircleShow : MonoBehaviour

{

public GameObject ParentObj;

public GameObject[] GroundObjectsArray;

public List GroundObjectsList = new List();

public SpriteRenderer[] SpriteGround;

void Awake()

 {

     SpriteGround = ParentObj.transform.GetComponentsInChildren<SpriteRenderer>();

     GroundObjectsArray = new GameObject[ParentObj.transform.childCount];

 }

void Update()

{

for (int i = 0; i < GroundObjectsArray.Length; i++) {

         GroundObjectsArray[i] = ParentObj.transform.GetChild(i).gameObject;

         //GroundObjectsArray[i].gameObject.SetActive(false);

         SpriteGround[i].color -= new Color(0, 0, 0, 255);

         ObjectsInArea(GroundObjectsArray[i]);


     }


}

// get which gameobject in circle area

public void ObjectsInArea(GameObject GroundObj)

 {

     if()

     {  
            GroundObjectsList.Add(GroundObj);
     }

 }

}


i new in unity and i use Physics2D.OverlapCircle but didn't work for me because it just return boolean(true , false) i need just calculation Gameobject in area set to list

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

2 Replies

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

Answer by Bunny83 · May 03, 2020 at 09:48 AM

When you are new to game development in general you should learn how to solve problems. First since you know you are working with Unity and you're using Physics2D you would do a google search for "Unity Physcis2D". The first result usually gives you the documentation for Physics2D. When you scroll down to the static methods you should look out for a method which might be useful for your problem. Most names are pretty straight forward to understand. If not there's a short description to the right. If that doesn't help you can visit the documentation page for that method which often comes with a small example code snippet and a (hopefully) better description.


You should come across the method Physics2D.OverlapCircleAll


ps: If you have a look at Physics2D.OverlapCircle you will notice that it does not return a boolean but the first Collider2D that is within that circle. This method is useful when you only look for a single object and that object can be isolated through layers.

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
avatar image
0

Answer by ArIaNFury008 · May 03, 2020 at 04:43 PM

thanks very much i was wrong Physics2D.overlapCircle it does not return a boolean My problem was solved :P

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

125 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I find a child object in a hierarchy of children? 1 Answer

Which is faster, GameObject.Find or GameObject.FindWIthTag? 2 Answers

Finding GameObject without using the full name 1 Answer

Find GameObject in another loaded scene 2 Answers

Searching a List of GameObjects by name 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