I am spawning instantiated objects which stacked on top of each other. I want to locate the stacked object by click. I am using overlapcircleall bu t it seems like it is not working.
Hope you guys can help.
My code snippet:
private Vector2 fp; // first position
private Vector2 lp; // last position
void Update () {
if (Input.GetMouseButtonDown (0)) {
fp = Input.mousePosition;
Debug.Log ("Button pressed at "+ fp );
Collider2D[] hitColliders = Physics2D.OverlapCircleAll(fp, 0, Physics2D.DefaultRaycastLayers,Mathf.Infinity,Mathf.Infinity);
foreach (Collider2D collider in hitColliders) {
Debug.Log ("Collided with: " + collider);
}
/*if (Input.GetMouseButtonUp (0)) {
lp = Input.mousePosition;
Debug.Log ("Button released at "+ lp);
}*/
}
}