How to check if PolygonCollider2D collides with any other collider?

Hello, i’m new to polygon collider, i am trying to find a way to check if polygoncollider2D collides with any other collider, i am using Collider2D.OverlapCollider but it is not working or maybe i am not using it properly, please help me thx.

First, there’s a dedicated physics forum here you can use for this stuff.

There are lots of ways to do this from using physics calbacks to you performing physics queries to just reading contacts between colliders.

You’ll need to provide more information for me to suggest which is appropriate.

If you’re absolutely new and don’t know much about physics at all then I would suggest a primer like this one here.

1 Like

I’m trying to use something that can check if any buildings have been built in this location. With Boxcollider2D, just using OverlapBox can solve that problem, right? but with polygonCollider2D I still don’t know how can I check it.

OverlapBox has nothing to do with BoxCollider2D apart from it defining a box. Queries are not colliders. There are no queries that defined an arbitrary polygon area.

If you use Collider2D.OverlapCollider then that checks if a certain collider in the scene is currently overlapping anything. It can be called on any Collider2D obviously. If it’s not working then you’re doing something wrong so maybe let’s try to figure that out.

I see this all the time; something doesn’t work so a completely different method is looked for. Let’s just figure out what you’re doing wrong instead. :slight_smile:

1 Like