Skip to content

Instantly share code, notes, and snippets.

@khakionion
Forked from sylistine/player.cs
Last active February 1, 2016 09:17
Show Gist options
  • Save khakionion/71b7680738268273121b to your computer and use it in GitHub Desktop.
Save khakionion/71b7680738268273121b to your computer and use it in GitHub Desktop.
void Update ()
{
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
{
HandleTouch();
}
}
void HandleTouch()
{
Touch touch = Input.GetTouch(0);
if(touch.phase == TouchPhase.Moved)
{
Vector3 cameraRelativeDeltaPosition = screenXY2CameraXZ(touch.deltaPosition);
playerOffset.x = playerOffset.x - cameraRelativeDeltaPosition.x;
playerOffset.z = playerOffset.z - cameraRelativeDeltaPosition.z;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment