I have a camera drag on my camera which allows the user to move it around the scene. However, when I drag the camera from side to side it moves forwards and backwards and then dragging the mouse up and down moves the camera from side to side. I would also like to be able to zoom the camera in and out though cannot seem to figure it out. Can anyone help please?
This is the code I am using:
using UnityEngine;
using System.Collections;
public class CameraDrag3: MonoBehaviour {
float speed = 20.0f;
void Update () {
if (Input.GetMouseButton (0)) {
if (Input.GetAxis ("Mouse X") > 0) {
transform.position += new Vector3 (Input.GetAxisRaw ("Mouse X") * Time.deltaTime * speed,
0.0f, Input.GetAxisRaw ("Mouse Y") * Time.deltaTime * speed);
}
else if (Input.GetAxis ("Mouse X") < 0) {
transform.position += new Vector3 (Input.GetAxisRaw ("Mouse X") * Time.deltaTime * speed,
0.0f, Input.GetAxisRaw ("Mouse Y") * Time.deltaTime * speed);
}
}
}
}