My script attach to tk2dcamera to drag camera axis x
public override void TouchDownOut (Vector2 position)
{
dragOrigin = new Vector3 (position.x, position.y, 0);
dragOrigin = camera.ScreenToWorldPoint(dragOrigin);
originTime = Time.time;
if(!isMove)
{
isMove = true;
}
}
public override void TouchMoveOut (Vector2 position)
{
Vector3 currentPos = new Vector3 (position.x, position.y, 0);
currentPos = camera.ScreenToWorldPoint(currentPos);
if(isMove)
{
if (Vector3.Distance(dragOrigin,currentPos) > 10f)
{
float amtToMove = 20f * Time.deltaTime;
LGController.state = LGController.State.Animation;
movePos = dragOrigin - currentPos;
movePos = new Vector3(movePos.x * amtToMove,movePos.y,movePos.z);
Vector3 newPos = transform.position + movePos;
newPos.y = this.transform.position.y;
transform.position = newPos;
}
}
}
public override void TouchUpOut (Vector2 position)
{
if(isMove)
{
isMove = false;
}
}
But it not smooth . Anyone help me ?