I developed a basic game in which the camera can be moved across the map using the WASD keys and i wanted to adapt the basic button actions to work on a touch screen , but I am unsure how to start.
Heres the c# code i currently have for moving the camera
if (Input.anyKey && allowInput)
{
moved = false;
if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) { moved = true; Translate(Vector3.forward * Time.deltaTime * speed); }
if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) { moved = true; Translate(Vector3.back * Time.deltaTime * speed);}
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) { moved = true; Translate(Vector3.left * Time.deltaTime * speed);}
if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) { moved = true; Translate(Vector3.right * Time.deltaTime * speed); }
if (OnCamManuallyMoved != null && moved)
{
Vector3 pos = tr.position;
if (pos.x < min_xz.x) pos.x = min_xz.x;
if (pos.x > max_xz.x) pos.x = max_xz.x;
if (pos.z < min_xz.y) pos.z = min_xz.y;
if (pos.z > max_xz.y) pos.z = max_xz.y;
tr.position = pos;
OnCamManuallyMoved(); // call callback
}
}