How can I get both colliders' types in a trigger overlap message like OnTriggerExit2D(Collider2D other)
?
Example:
objects A and B
both have aBoxCollider2D
andCircleCollider2D
components.Then,
object A
enters one of the trigger colliders ofobject B
.I can get
object B
's collider type with theis
operator.
How can I get A's collider type?
The reason I want this is that I want only collisions where object A
's CircleCollider2D
touches object B
's BoxCollider2D
.
void OnTriggerExit2D(Collider2D other)
{
if (other is BoxCollider2D)
//Do Code
}
Here is a table of what I want: I want only to register trigger overlaps from CircleCollider2D to BoxCollider2D
. With the is
operator, I can safely remove all collisions to CircleCollider2D
but collisions between two BoxCollider2D
stay, which I do not want.
+------------------+---------------+------------------+
| Row to Column | BoxCollider2D | CircleCollider2D |
+------------------+---------------+------------------+
| BoxCollider2D | No | No |
| CircleCollider2D | Yes | No |
+------------------+---------------+------------------+
Edit The real questions was to detect nearby objects without the detection range dectecting each other.