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
2
Question by sneftel · Jul 16, 2011 at 03:05 PM · physicscollider

Manual collision check

Given two colliders -- ones, in fact, which have no rigid body and are marked "static" and "trigger" -- is it possible to manually check for overlap between them? I guess I could unstatic them and give them rigid bodies and see what happens, but ideally I'd like to do this during Start(), so that's not an option there. I suppose I could implement the collision test myself, for the collider pairs I need, but I'd really like to avoid that if possible. Any clever ideas?

Comment
Add comment · Show 2
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 ne0r · May 20, 2012 at 12:06 PM 0
Share

hey,

i got the same problem. Did u ever find a solution or came up with your own code?

avatar image Bunny83 · May 20, 2012 at 01:02 PM 0
Share

btw. static checkbox has no effect on colliders, see "static checkbox"

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by BoredKoi · Jul 16, 2011 at 05:23 PM

Manual collider checks are done via two static functions...Physics.OverlapSphere will return an array of the colliders touching the caller object and Physics.CheckSphere (quicker) is a bool that indicates overlap/contact exists.

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 sneftel · Jul 16, 2011 at 06:39 PM 0
Share

Sphere checks (and capsule checks) are straightforward, of course... but there's no function there to check box colliders, particularly non-axis-aligned ones.

avatar image BoredKoi · Jul 16, 2011 at 07:25 PM 0
Share

Yep, that's a more specific problem (boxes) -- how about collider.bounds.Intersects? Or if not the collider (speaking to axis-alignment) try renderer.bounds.Intersects perhaps...

avatar image sneftel · Jul 16, 2011 at 08:49 PM 1
Share

Unfortunately, both of those are world-space axis-aligned. It's frustrating, because of course Unity is more than capable of doing the check, for any collider pair (other than concave meshcolliders); it simply deigns not to expose that functionality.

avatar image
2

Answer by Bunny83 · May 20, 2012 at 01:00 PM

You can use Rigidbody.SweepTest to check manually for collisions. I'm not sure if collisions with triggers are detected as well, but it's worth a try.

Collision detection is done by the physics system. Colliders are pure passive objects. Only rigidbodies can perform collision tests.

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 Tortuap · Nov 23, 2015 at 08:17 PM 0
Share

Collisions with triggers are detected as well, accordingly to a specific parameter that indicates to include or exclude them from the test result.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

If statment to check if player is within collider 1 Answer

Collect some coins for Points 1 Answer

Continuously moving rigidbody 2 Answers

Physics.Raycast not checking layermask properly? 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