OverlapSphere with Box Collider 2d

I’m trying the new 2D features of unity, and I create a sprite object, add a box collider 2D, and a simple script that uses OverlapSphere() to detect colliders. It returns 0 colliders, even when I attach this script to an object that has a collider attached to it:

// Use this for initialization
void Start () {
	Collider[] colliders = Physics.OverlapSphere(transform.position, 5);
	Debug.Log(colliders.Length + " colliders in range ");
}

Obviously, at least the object itself should appear in the results… Changing to regular box collider (3D) works fine.

Any ideas? Unity bug?

Along with collider2D, they also have the Physics2D library, you may be able to find the answer there. cheers mate :slight_smile:

Apparently there’s a Physics2D class, which handles physics in 2D modes. There’s a matching Physics2D.OverlapCircleAll() which is the OverlapSphere equivalent of 2D.

I guess the most important thing I learned is to read the release notes which state the new classes for using 2D.