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 DevMerlin · Nov 18, 2014 at 01:20 PM · physicsoverlapspherespherecastspherecastall

Which is more efficent? SphereCast, SphereCastAll, or OverlapSphere?

I am attempting to track and 'catch' balls in a multiball situation, so I need to know how to locate these balls and have my glove go after them. Each ball is tagged with a "Ball" tag, and the 'glove' uses it's transform and rigidbody in order to predict where the ball is going to land. Which method would be the best to target individual balls within range, select a random one and go after it?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
4

Answer by HarshadK · Nov 18, 2014 at 01:42 PM

An OverlapShpere will give you all the balls within certain radius of your glove whereas a SphereCastAll will perform a sweep in the specified direction with a specified radius for the sphere (SphereCast will just report the first collider). So in your case OverlapShpere is what you need.

Also you can select a random ball from the list of returned colliders array by OverlapShpere. Or you can calculate distance of each ball from glove and then select a ball based on distance. This is really up to you as how you want to do it and how you want your gameplay to be.

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 tanoshimi · Nov 18, 2014 at 01:48 PM 1
Share

You got there before me ;) @Harshad$$anonymous$$ is correct - the choice is not a matter of efficiency, it's a matter of choosing the right functionality for your application.

avatar image DevMerlin · Nov 18, 2014 at 01:48 PM 0
Share

I had a thought that perhaps I could use a wide sphere collider and OnTriggerEnter to detect each ball, but I have no idea if this is more or less efficient.

avatar image HarshadK · Nov 18, 2014 at 02:00 PM 0
Share

@tanoshimi Just a tad bit of luck.

@Teonnyn If you are going to perform an OverlapSphere in each Update then you should consider using wide sphere collider and OnTriggerEnter since it will be efficient than OverlapShpere in each Update. It is a matter of consideration based upon how your need it to be. If you could elaborate on your precise needs then we might be able to provide something solid.

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

26 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

Related Questions

How do you perform a stationary SphereCastAll? 1 Answer

SphereCast not hitting the box bollider correctly 0 Answers

Generating lines between procedurally instantiated gameobjects, within a certain radius 1 Answer

Spherecast Arguments 1 Answer

OverlapSphere and QueryTriggerInteraction 1 Answer


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