Hi guys, I’m working on a 2D game and am trying to work on a problem of moving a 2D object with transform.position. What I’m trying to do is move an object with mouse click and drag, and moving said object by altering its transform. What I want is to make sure that on release, the object isn’t lying on another object, so I thought the best way to check would be with Physics2D.OverlapCircle(mouse release point, object radius), but that clearly doesn’t work because the said gameObject is in that area. Is there any way to get the function to ignore specific gameObject, or is there some better way? Any help would be appreciated. Thanks!
Here’s a bit of my code for reference:
Vector3 currPos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
Vector2 curr2DPos = newVector2 (currPos.x, currPos.y);
if (Physics2D.OverlapCircle (curr2DPos, radius)) {
transform.position = startPos;
} else …