I am making a 2D level editor and when I am placing a sprite over another collider it should prevent me from being able to place the item. When the collider being placed is completely over an item it's pretty consistent with saying placement is blocked, but when any of the sprites are slightly off of the sprite that is already on the map, the state of the overlapping collider is flickering between blocked and not. If someone thinks there is a better way to handle this for the level editor, I am all ears. I am not sure why the overlap collider is not consistent when it is partially overlapping something.
public bool CanPlaceObject()
{
Collider2D collider = GetComponent<Collider2D>();
ContactFilter2D filter = new ContactFilter2D();//.NoFilter();
filter.SetLayerMask(Mask);
List<Collider2D> results = new List<Collider2D>();
int colCount = collider.OverlapCollider(filter, results);
if (colCount > 0)
{
sr.color = cannotPlaceColor;
return false;
}
sr.color = canPlaceColor;
return true;