Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. void FixedUpdate()
  2. {
  3. foreach (Touch touch in Input.touches)
  4. {
  5. if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
  6. {
  7. Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
  8. Vector2 pos = touchDeltaPosition;
  9. pos.x = touchDeltaPosition.x * speed;
  10. pos.y = touchDeltaPosition.y * speed;
  11. transform.Translate(pos.x,pos.y,0);
  12.  
  13. Ray ray = Camera.main.ScreenPointToRay(touch.position);
  14. RaycastHit hit;
  15.  
  16. if (Physics.Raycast(ray, out hit, 1000))
  17. {
  18. if (hit.collider.tag=="Environment")
  19. {
  20. Cubecall();
  21. }
  22. }
  23. }
  24. }
  25. }
  26. void Cubecall()
  27. {
  28. anim.enabled = true;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement