Advertisement
LittleAngel

Controller for EZGui

Dec 28th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. void Move (ref POINTER_INFO ptr) {
  2. if (ptr.active) {
  3. if (controller.isGrounded) {
  4. // We are grounded, so recalculate movement directly from axes
  5. if (ptr.evt == POINTER_INFO.INPUT_EVENT.DRAG) {
  6. stickPosition.x = ptr.devicePos.x - ptr.origPos.x;
  7. stickPosition.z = ptr.devicePos.y - ptr.origPos.y;
  8. }
  9. }
  10.  
  11. // Reposition the moveButton Control Graphic
  12. offset.x = Mathf.Clamp(stickPosition.x, -dragBoundary, dragBoundary);
  13. offset.y = Mathf.Clamp(stickPosition.z, -dragBoundary, dragBoundary);
  14. }
  15.  
  16. // The pointer has released the moveButton Control Graphic, so reset its position
  17. if (ptr.evt == POINTER_INFO.INPUT_EVENT.RELEASE || ptr.evt == POINTER_INFO.INPUT_EVENT.RELEASE_OFF) {
  18. offset = Vector3.zero;
  19. stickPosition = Vector3.zero;
  20. }
  21.  
  22. moveButton.SetOffset(offset);
  23. }
  24.  
  25. void Jump (ref POINTER_INFO ptr) {
  26. if (ptr.evt == POINTER_INFO.INPUT_EVENT.TAP || ptr.evt == POINTER_INFO.INPUT_EVENT.PRESS) {
  27. if (controller.isGrounded) {
  28. jumpNow = true;
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement