My camera moves in the opposite direction to my mouse!

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);  

	}
}
		
}

}

I don’t think you need that if statement.

This could be any number of things, but what is the rotation on your camera? Are you sure that its local forward / right vectors are oriented to give you those results?

Try this:

void Update () {

	// Start with our current location
	Vector3 newPosition = transform.position;
	
	// Increment based on the mouse motion
	newPosition += transform.right * Input.GetAxisRaw ("Mouse X") * Time.deltaTime * speed;
	newPosition += transform.up * Input.GetAxisRaw ("Mouse Y") * Time.deltaTime * speed;
	
	// Reassign the vector
	transform.position = newPosition;
 }

public GameObject head; //Select camera in editor or head for rotating

float axis1;

float axis2;

float speedX=20;

float speedY=20;

void Update()
{

Screen.lockCursor = true;

axis1 -= speedX * Input.GetAxis(“Mouse X”);

axis2 += speedY * Input.GetAxis(“Mouse Y”);

axis1 = Mathf.Clamp(axis1, -45, 45);

axis2 = Mathf.Clamp(axis2, -60, 60);

head.transform.localEulerAngles = new Vector3(axis1, axis2,0);

}


This is the easiest way to rotate camera or head with mouse moving!