Created
February 1, 2016 09:12
-
-
Save sylistine/50f5a28ea4430f333980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool handlingInput = false; | |
void Update () | |
{ | |
if(!handlingInput) | |
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) | |
{ | |
handlingInput = true; | |
StartCoroutine(HandleTouch()); | |
} | |
} | |
IEnumerator HandleTouch() | |
{ | |
Touch touch = Input.GetTouch(0); | |
while (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) | |
{ | |
if(touch.phase == TouchPhase.Moved) | |
{ | |
Vector3 cameraRelativeDeltaPosition = screenXY2CameraXZ(touch.deltaPosition); | |
playerOffset.x = playerOffset.x - cameraRelativeDeltaPosition.x; | |
playerOffset.z = playerOffset.z - cameraRelativeDeltaPosition.z; | |
} | |
yield return new WaitForEndOfFrame(); | |
touch = Input.GetTouch(0); | |
} | |
handlingInput = false; | |
yield return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment