Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

a relation between Touch Move and Screen Size

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

  1. Daniel-Liu

    Daniel-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:
    79
    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