title: Unity3d move object along plane (X and Z axis only)
body: <p>I have a Unity3D project.  This project has a prefab I created (a table top) with a plane as the top of the able.  The plane has a box colider and rigid body.  On the table top, I have another object.  I want to move this object only around the table top (X and Z axis).  The object should never be raised above the table top.  I have this code attached to my object:</p>
  
  <pre><code>void OnMouseDown()
  {
      Debug.Log("mouse down");
      screenPoint = Camera.main.WorldToScreenPoint(transform.position);
      offset = transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
  }
  
  void OnMouseDrag()
  {
      Debug.Log("mouse drag");
      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 moves the object around but it also moves the object above the table top.  Is there a way to keep the object on the table?</p>