Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. void moveMesh()
  2. {
  3. if (Input.GetMouseButtonDown(0))
  4. {
  5. mouseClickPos = Input.mousePosition;
  6. }
  7.  
  8. if (Input.GetMouseButton(0))
  9. {
  10. screenPoint = Camera.main.WorldToScreenPoint(myMesh.transform.position);
  11. Vector3 mouseOffsetAmount = mouseClickPos - Input.mousePosition;
  12. Vector3 cursorPoint = new Vector3(screenPoint.x+mouseOffsetAmount.x, screenPoint.y+mouseOffsetAmount.y, screenPoint.z);
  13.  
  14. Vector3 finalPos = Camera.main.ScreenToWorldPoint(cursorPoint);
  15. myMesh.transform.position = finalPos;
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement