title: How to detect collisions when using a GameObject collides with a BoxCollider 2D while being dragged on Unity 3D
body: <p>I've created a simple drag script. This will be the main input of my game and that's how I'll control the player. The script can be seen below:</p>
  
  <pre><code>public void OnMouseDown() {
      offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
  
      if (gameController.GetCurrentState () != GameStates.INGAME){
          gameController.StartGame();
      }
  }
  
  public void OnMouseDrag() {
      if (gameController.GetCurrentState () == GameStates.INGAME) {
          Vector3 curScreenPoint = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
          Vector3 curPosition = Camera.main.ScreenToWorldPoint (curScreenPoint) + offset;
          transform.position = curPosition;
      }
  }
  </code></pre>
  
  <p>This script is attached to my player. Also attached to my player is a RigidBody 2D and Circle Collider 2D. I've created some walls and at game start, I'm repositioning it outside of the camera using mainCam.ScreenToWorldPoint. This is done with: </p>
  
  <pre><code>var mainCam : Camera;
  
  var topWall : BoxCollider2D;
  var bottomWall : BoxCollider2D;
  var leftWall : BoxCollider2D;
  var rightWall : BoxCollider2D;
  
  //Reference the players
  
  function Start () {
  
      //Move each wall to its edge location:
      topWall.size = new Vector2 (mainCam.ScreenToWorldPoint (new Vector3 (Screen.width * 2f, 0f, 0f)).x, 1f);
      topWall.center = new Vector2 (0f, mainCam.ScreenToWorldPoint (new Vector3 ( 0f, Screen.height, 0f)).y + 0.5f);
  
      bottomWall.size = new Vector2 (mainCam.ScreenToWorldPoint (new Vector3 (Screen.width * 2, 0f, 0f)).x, 1f);
      bottomWall.center = new Vector2 (0f, mainCam.ScreenToWorldPoint (new Vector3( 0f, 0f, 0f)).y - 0.5f);
  
      leftWall.size = new Vector2(1f, mainCam.ScreenToWorldPoint(new Vector3(0f, Screen.height*2f, 0f)).y);;
      leftWall.center = new Vector2(mainCam.ScreenToWorldPoint(new Vector3(0f, 0f, 0f)).x - 0.5f, 0f);
  
      rightWall.size = new Vector2(1f, mainCam.ScreenToWorldPoint(new Vector3(0f, Screen.height*2f, 0f)).y);
      rightWall.center = new Vector2(mainCam.ScreenToWorldPoint(new Vector3(Screen.width, 0f, 0f)).x + 0.5f, 0f);
  }
  </code></pre>
  
  <p>Like the player, this walls also have RigidBody 2D and Box Collider 2D attached to it. My problem is that I'm not able to detect any kind of collision. Not even when I drag the ball up to the walls. Mine intend with this script is detect if, while dragging, you touched the walls. By doing that, I'll be able to call my game state "GameOver" and end the game.</p>
  
  <p>Any idea about WHY, I'm not able to detect this collisions? I'm sure that the walls are in the right position and the ball is indeed touching the walls.</p>