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?
i got the same problem. Did u ever find a solution or came up with your own code?
btw. static checkbox has no effect on colliders, see "static checkbox"
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.
Sphere checks (and capsule checks) are straightforward, of course... but there's no function there to check box colliders, particularly non-axis-aligned ones.
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...
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.
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.
Collisions with triggers are detected as well, accordingly to a specific parameter that indicates to include or exclude them from the test result.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users post good questions and use the site effectively we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
6 People are following this question.
The name 'Joystick' does not denote a valid type ('not found')
Creating a SIMPLE car.
Collect some coins for Points
If statment to check if player is within collider
Get a bounding sphere for collider/rigidbody?