TeHArGiS10

Untitled

Apr 12th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Control : MonoBehaviour
  6. {
  7.  
  8. public Vector2 mousePos;
  9. public Transform mouseFollow;
  10. public bool mouseTouch = false;
  11.  
  12. public void Update()
  13. {
  14. mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
  15. mouseFollow.transform.position = mousePos;
  16.  
  17. if (Input.GetMouseButton(0))
  18. {
  19. if (mouseTouch)
  20. {
  21. transform.position = mousePos;
  22. }
  23. }
  24. }
  25. private void OnTriggerEnter(Collider other)
  26. {
  27. mouseTouch = true;
  28. }
  29.  
  30. private void OnTriggerExit(Collider other)
  31. {
  32. mouseTouch = false;
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment