I have this code here that pans my scene with the camera on both the x-axis and y-axis. I've changed my mind and only want to pan down and up on the y-axis but keep the x-axis the same, how could I edit the script to do so? Thanks! :)
void LateUpdate () {
if (Input.GetMouseButtonDown(0)){
touchStart = GetWorldPosition(groundZ);
}
if (Input.GetMouseButton(0)){
Vector3 direction = touchStart - GetWorldPosition(groundZ);
cam.transform.position += direction;
}
}
private Vector3 GetWorldPosition(float z){
Ray mousePos = cam.ScreenPointToRay(Input.mousePosition);
Plane ground = new Plane(Vector3.forward, new Vector3(0,0,z));
float distance;
ground.Raycast(mousePos, out distance);
return mousePos.GetPoint(distance);
}