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
1
Question by MileSplit · Feb 11, 2013 at 12:22 AM · javascriptfind

Get all Game Objects near point

Hello, Im sorry if this has been asked but ive searched and cant find a thing.

So, I was wondering how to get all objects near a point like the title says.

I would Prefer NOT to use raycasts because my object may have a different Y cord.

Thanks, I use Unity Script

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 leonalchemist · Feb 11, 2013 at 12:45 AM 0
Share

depends on the type of object ur using, was thinking if its a player or any other moving object, dunno how efficient it is but u could create a sphere collider around the object u want to count game objects and using OnTriggerEnter function, everytime u hit a tagged object or something u do count + 1, and count - 1 on OnTriggerExit

avatar image MileSplit · Feb 11, 2013 at 01:09 AM 0
Share

Sorry in my position that would be very bad.

avatar image MileSplit · Feb 11, 2013 at 01:11 AM 0
Share

Ok, all i wanted to know is if there was some simple function like, GameObjectsNearPoint ect. idk

But there is not i guess. Thanks for your answers.

2 Replies

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

Answer by cdrandin · Feb 11, 2013 at 01:05 AM

The way I see this is like there is some gravitational pull at some place, i.e. could be some super villain just to paint a nice picture. Now this spell would move all nearby objects towards the origin of the pull. You will need to do a lot of math to get the objects to move towards the center if you want the objects to move based on their current rotation or you can simplify it by having the game objects LookAt the origin of the pull which causes them to turn around with the Z axis pointing towards the origin, then just add a force to them and they will all move uniformly.

To get some cool stuff happening you would need rigidbody and customize each objects mass, and resistance, but if you just want a simple pull then just make your own move to center function.

Comment
Add comment · Show 3 · 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 MileSplit · Feb 11, 2013 at 01:09 AM 0
Share

Thats not even close to what i want, but thanks for the answer.

avatar image cdrandin · Feb 11, 2013 at 01:19 AM 0
Share

Ok now because of your previous post I now understand what you are talking about. Check out:

  • http://docs.unity3d.com/Documentation/ScriptReference/Physics.SphereCast.html

  • http://docs.unity3d.com/Documentation/ScriptReference/Physics.SphereCastAll.html

  • RaycastHit

Sorry for the confusion.

avatar image ArtOfWarfare cdrandin · May 07, 2016 at 01:42 AM 0
Share

SphereCast is the wrong answer - sphere cast is for finding if there are objects within a capsule shape (the documentation says to think of it like a thick linecast). The correct answer is Physics.OverlapSphere.

Also, the question was perfectly clear.

avatar image
4

Answer by alibatiste · Dec 02, 2013 at 09:42 AM

I think this function solve your problem: http://docs.unity3d.com/Documentation/ScriptReference/Physics.OverlapSphere.html

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

12 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

Related Questions

Do not destroy a transform 1 Answer

Substitute of collision 2 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Refactoring & Find References for JavaScript in MonoDevelop 1 Answer

GameObject.Find() sometimes fails, is that okay? 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