Question by
JWijst · Jun 04, 2020 at 03:49 PM ·
collider2dtilemap
Tilemap Collider 2D with Physics2D.OverlapCircleAll doesn't collide correctly
I've got a Grid with a Tilemap in it and this Tilemap has a Tilemap Collider 2D. Now the character in my scene wants to know for that Tilemap when a tile is in range.
I've got:
Collider2D[] hitColliders = Physics2D.OverlapCircleAll(new Vector2(transform.position.x, transform.position.y), MaxDistance, mask);
foreach (var collider in hitColliders)
{
Gizmos.color = Color.red;
Gizmos.DrawLine(transform.position, collider.transform.position);
}
And a red line is drawn when it's hits a tile. But it's drawn toward the end of the Tilemap Collider 2D it seems.
As you can see the red line isn't drawn to the tile with snow (which is in the Tilemap with the right mask) but it's drawn toward the edge of that Tilemap collider.
What I want is to find the tiles within the radius within that mask. And draw lines to them.
unityquestion.png
(21.1 kB)
unityquestion.png
(21.1 kB)
Comment