OverlapCollider - colliding with object even when not touching it

Hey all,
I am creating an OverlapCollider to find out, if something is colliding with it. I am also drawing it.

But even though, that in the scene the collider doesn’t seem to touch the object ( its about 3 cm above it), a collision seems to be happening. The collision with cube 1.7 is correct, the collision with cube 2 should not happen from my point of view. I have checked the collider of the cube 2, and it’s fine.

Both, the Collider and the drawWireCube are placed at the same center with the same dimensions, so I don’t understand how this could happen.

Any ideas, what is going wrong here? Either the drawCube is not drawn where the Collider really is or I don’t know… I’m afraid it’s something stupid, but I just can’t figure it out…

My code:

data.ledgePoint = new Vector3(hit.point.x, hit.point.y + 0.03f, hit.point.z) ;
if (data.isCrouching)
      data.dimensions = new Vector3(0.84f, 1.6f, 0.84f);
      data.center = new Vector3(data.ledgePoint.x + (data.dimensions.x / 2), data.ledgePoint.y + 0.8f, data.ledgePoint.z);
      data.dimensions = new Vector3(0.6f, 2.1f, 0.6f);
      data.center = new Vector3(data.ledgePoint.x + (data.dimensions.x / 2), data.ledgePoint.y + 1.05f, data.ledgePoint.z);

Collider[] spaceCollider = Physics.OverlapBox(data.center, data.dimensions, Quaternion.identity, ~data.playerLayer);

int i = 0;
while (spaceCollider.Length != 0 && i < spaceCollider.Length)
     Debug.Log("Hit: " + spaceCollider[i].name);

void OnDrawGizmos()
     Gizmos.color = Color.red;
     Gizmos.DrawWireCube(data.center, data.dimensions);

Thank you Huxi.

As a small test, can you see if raising that “+ 0.03f” value stops this? Is there any value that does stop it? That may help figure out what’s causing this issue.

After testing, it turns out the second parameter you pass to the Physics.OverlapBox is called “halfExtents”, which means you actually need to divide the vector3 value you pass in by 2 in order to match the gizmo box’s position AND dimensions.
Let me know if this fixes the issue, and feel free to mark this as resolved if so!