Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OnMouseDrag() {
- Vector3 curScreenPoint = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenPoint.z); // Current touch point
- Vector3 curPosition = Camera.main.ScreenToWorldPoint (curScreenPoint) + offset; // Current touch point converted to point in scene
- if (!isClone) {
- clone.transform.position = curPosition; // Move clone to this position
- } else {
- // transform.position = curPosition; // non clamped version
- // Mathf.Clamp() restricts the movement of the dragged FB to the working area
- transform.parent.position = new Vector3 (
- Mathf.Clamp (curPosition.x,
- (breadboardLeft.position.x+breadboardLeft.GetComponent<BoxCollider2D>().bounds.size.x)+0.4f,
- breadboardRight.position.x-breadboardRight.GetComponent<BoxCollider2D>().bounds.size.x),
- curPosition.y,
- curPosition.z);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement