Advertisement
S0m3guy

Untitled

Jun 4th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. void OnMouseDrag() {
  2.             Vector3 curScreenPoint = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);         // Current touch point
  3.    
  4.             Vector3 curPosition = Camera.main.ScreenToWorldPoint (curScreenPoint) + offset;                             // Current touch point converted to point in scene
  5.             if (!isClone) {
  6.                 clone.transform.position = curPosition;                                                                         // Move clone to this position
  7.             } else {
  8.     //          transform.position = curPosition;       // non clamped version
  9.                 // Mathf.Clamp() restricts the movement of the dragged FB to the working area
  10.                 transform.parent.position = new Vector3 (
  11.                     Mathf.Clamp (curPosition.x,
  12.                         (breadboardLeft.position.x+breadboardLeft.GetComponent<BoxCollider2D>().bounds.size.x)+0.4f,
  13.                         breadboardRight.position.x-breadboardRight.GetComponent<BoxCollider2D>().bounds.size.x),
  14.                     curPosition.y,
  15.                     curPosition.z);
  16.             }
  17.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement