Search Unity

a relation between Touch Move and Screen Size

Discussion in 'Physics' started by YanLin-Liu, Jan 7, 2015.

  1. YanLin-Liu

    YanLin-Liu

    Joined:
    Jan 7, 2015
    Posts:
    2
    i want to move camera
    no matter touch or mouse , maybe it has a relation between deltaposition and screensize,i think.
    QQ截图20150107163405.png

    1. i want to , finger's equal with camera in deltapostion
    2. finger's deltapsition better than camera position , when screen size is too large
    3. finger's deltapsition less than camera position , when screen size is too small

    e.g screen aspect is 1280 800. let's reduce it acrroding to the proportion. it will show "2".

    how can i handle it...
     
  2. A_never_kill

    A_never_kill

    Joined:
    Jan 7, 2014
    Posts:
    81
    Hi daniel,
    You can do the code given below.
    if(Input.GetMouseButtonDown(1))
    {

    mouseOrigin = Input.mousePosition;
    isPanning = true;
    }
    if (isPanning)
    {
    Vector3pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - mouseOrigin);
    Vector3move = newVector3(pos.x * panSpeed, pos.y * panSpeed, 0);
    transform.Translate(move, Space.Self);
    }

    Thanks