Is there a way to filter some colliders out?

I have many objects with box colliders attached to them, each of arbitrary size and position, like on the picture. If i get all the colliders those blue collider collides with, i will get a list that contains all green and red colliders. I want to use blue trigger collider to only store collisions with green colliders. Difference between red and green colliders is that red ones only have a single point where they touch the blue one, or a single line in 3d space.

Is this possible to somehow exclude the red colliders from the list?

Any help is highly appreciated!


Its better if you use raycasting instead of boxcolliders.

Its difficult to check where the box collider collision is occuring from and which collider are the ones we need.

Raycasting is better because you can put rays on places where you want to recieve data from, In your case every point except the corners.

You can use several approaches: