- Home /
The question is answered, right answer was accepted
Make Physics2D.Raycast ignore triggers but Physics2D.OverlapBox doesn't?
I need raycasts for my game, and I want them to ignore triggers, but I still need Physics2D.OverlapBox detect them. How can I do this?
As far as i know, Raycast doesn't detect triggers, because they don't collide with anything, so it can't collide with the Raycast. And about the OverlapBox, maybe you could change to Physics.OverlapBox because it provides a parameter for setting the QueryTriggerInteraction, which lets you decide if it should hit triggers or not. https://docs.unity3d.com/ScriptReference/Physics.OverlapBox.html
Problem is, raycast DOES detect triggers, unless you set queriesHitTriggers to false, but that also makes OverlapBox ignore them.
Oh really, did not know that. And it wouldn't be possible to turn it off when raycasting, turn it on, do the overlapbox, turn it off... repeat..?