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 DemianT · Jul 06, 2013 at 10:07 PM · physicsraycastcolliderspherecast

SphereCastAll doesn't seem to be working

In desperation, I tried this:

RaycastHit[] hits = Physics.SphereCastAll(transform.position, 100000000f, transform.up, 100f);

and it STILL didn't work. It returned SOME hits but not all. My world just consists of a small room with some objects in it. Some with rigid bodies, some with only colliders. They are all in the default layer. This behavior just seems completely nonsensical. Can this be anything other than a bug in SphereCastAll?

Thanks

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
2

Answer by manzolo · Jul 11, 2013 at 05:31 PM

do you have any colliders set to triggers ? spherecast only detects colliders that are not set up as triggers, so any colliders that have is trigger option checked wont be detected by the spherecollider

Comment
Add comment · Show 2 · 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 DemianT · Jul 11, 2013 at 09:15 PM 0
Share

Nope, no triggers.

avatar image manzolo · Jul 12, 2013 at 04:12 PM 0
Share

hm have you tried setting the radius to 0.1 to see if you get a different result ?

avatar image
1

Answer by robertbu · Jul 06, 2013 at 10:29 PM

If the object is already inside radius, it will not be detected. You can handle this in a couple of different ways. Image you wanted a radius of 10.0. You can do:

 RaycastHit[] hits = Physics.SphereCastAll(transform.position-transform.up*10.0, 10.0f, transform.up, 100f).

Another possibility is to do a Physics.OverlapSphere()first, and then to add any new items found by call to Physics.SphereCastAll() with a radius the same size.

Comment
Add comment · Show 1 · 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 DemianT · Jul 07, 2013 at 08:56 AM 0
Share

Thank you for your answer. There are two problems with that.

1) When I use radius 100000000f, I actually do get some 'hits'. Though that number seems to change, sometimes 2, or 5 or 6 hits. And I can assure you that I don't have any objects that far out.

2) Conceptually, OverlapSphere would be perfect for me. But in the documentation it says that it presently only checks for collisions with other objects' bounding boxes rather than the colliders themselves. That would be fine if there was some other physics query function to check for a collision between a given pair of colliders, but afaik there is no such function.

This seems crazy. All I want to do is check, when the user clicks, whether there is something within a certain radius of a given position (or ideally within an arbitrary shape). I would have thought that to be a very common usage?

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

16 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

Related Questions

SphereCast Arguments 1 Answer

Raycast hits when missing a collider, misses when hitting a collider? 0 Answers

Prevent shooting when gun is inside wall 1 Answer

Colliders attached to objects on separate layers are colliding? 1 Answer

How do you perform a stationary SphereCastAll? 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