Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Move (ref POINTER_INFO ptr) {
- if (ptr.active) {
- if (controller.isGrounded) {
- // We are grounded, so recalculate movement directly from axes
- if (ptr.evt == POINTER_INFO.INPUT_EVENT.DRAG) {
- stickPosition.x = ptr.devicePos.x - ptr.origPos.x;
- stickPosition.z = ptr.devicePos.y - ptr.origPos.y;
- }
- }
- // Reposition the moveButton Control Graphic
- offset.x = Mathf.Clamp(stickPosition.x, -dragBoundary, dragBoundary);
- offset.y = Mathf.Clamp(stickPosition.z, -dragBoundary, dragBoundary);
- }
- // The pointer has released the moveButton Control Graphic, so reset its position
- if (ptr.evt == POINTER_INFO.INPUT_EVENT.RELEASE || ptr.evt == POINTER_INFO.INPUT_EVENT.RELEASE_OFF) {
- offset = Vector3.zero;
- stickPosition = Vector3.zero;
- }
- moveButton.SetOffset(offset);
- }
- void Jump (ref POINTER_INFO ptr) {
- if (ptr.evt == POINTER_INFO.INPUT_EVENT.TAP || ptr.evt == POINTER_INFO.INPUT_EVENT.PRESS) {
- if (controller.isGrounded) {
- jumpNow = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement