# How to set camera movement

My FPS camera will follow accordance to what I press but will not rotate along, its only facing forward even when I backward my character, I have to use right click and press my mouse to rotate manually and this will not work in android and so on. How to make the camera rotate along and smooth?

Here the mouselook.js script

``````using UnityEngine;
``````

using System.Collections;

public class MouseLook : MonoBehaviour {

public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F;
public float sensitivityY = 15F;

public float minimumX = -60F;
public float maximumX = 60F;

public float minimumY = -60F;
public float maximumY = 60F;

public float offsetY = 0F;
public float offsetX = 0F;

public float rotationX = 0F;
GameObject cmra = null;

public float rotationY = 0F;

Quaternion originalRotation;

void Update ()
{
if (axes == RotationAxes.MouseXAndY)
{
// Read the mouse input axis
rotationX += (Input.GetAxis(“Mouse X”) * sensitivityX /30cmra.camera.fieldOfView + offsetX);
rotationY += (Input.GetAxis(“Mouse Y”) * sensitivityY /30
cmra.camera.fieldOfView + offsetY);

rotationX = ClampAngle (rotationX, minimumX, maximumX);
rotationY = ClampAngle (rotationY, minimumY, maximumY);

Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, Vector3.left);

transform.localRotation = originalRotation * xQuaternion * yQuaternion;
}
else if (axes == RotationAxes.MouseX)
{
rotationX += (Input.GetAxis(“Mouse X”) * sensitivityX /60*cmra.camera.fieldOfView + offsetX);
rotationX = ClampAngle (rotationX, minimumX, maximumX);

Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
transform.localRotation = originalRotation * xQuaternion;
}
else
{
rotationY += (Input.GetAxis(“Mouse Y”) * sensitivityY /60*cmra.camera.fieldOfView + offsetY);
rotationY = ClampAngle (rotationY, minimumY, maximumY);

Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, Vector3.left);
transform.localRotation = originalRotation * yQuaternion;
}
offsetY = 0F;
offsetX = 0F;
}

void Start ()
{
cmra = GameObject.FindWithTag(“MainCamera”);
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
originalRotation = transform.localRotation;
}

public static float ClampAngle (float angle, float min, float max)
{
if (angle < -360F)
angle += 360F;
if (angle > 360F)
angle -= 360F;
return Mathf.Clamp (angle, min, max);
}
}

```using UnityEngine;
using System.Collections;

public class MouseLook : MonoBehaviour
{
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F;
public float sensitivityY = 15F;

public float minimumX = -60F;
public float maximumX = 60F;

public float minimumY = -60F;
public float maximumY = 60F;

public float offsetY = 0F;
public float offsetX = 0F;

public float rotationX = 0F;
GameObject cmra = null;

public float rotationY = 0F;

Quaternion originalRotation;

bool mouseControlEnabled = false;

void Update()
{
if (Input.GetMouseButtonDown(1))
{
mouseControlEnabled = !mouseControlEnabled;
if (!mouseControlEnabled)
{
rotationX = 0f;
rotationY = 0f;
transform.localRotation = originalRotation;
}
}
if (mouseControlEnabled)
{
if (axes == RotationAxes.MouseXAndY)
{
// Read the mouse input axis
rotationX += (Input.GetAxis("Mouse X") * sensitivityX / 30 * cmra.camera.fieldOfView + offsetX);
rotationY += (Input.GetAxis("Mouse Y") * sensitivityY / 30 * cmra.camera.fieldOfView + offsetY);
rotationX = ClampAngle(rotationX, minimumX, maximumX);
rotationY = ClampAngle(rotationY, minimumY, maximumY);
Quaternion xQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up);
Quaternion yQuaternion = Quaternion.AngleAxis(rotationY, Vector3.left);
transform.localRotation = originalRotation * xQuaternion * yQuaternion;
}
else if (axes == RotationAxes.MouseX)
{
rotationX += (Input.GetAxis("Mouse X") * sensitivityX / 60 * cmra.camera.fieldOfView + offsetX);
rotationX = ClampAngle(rotationX, minimumX, maximumX);
Quaternion xQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up);
transform.localRotation = originalRotation * xQuaternion;
}
else
{
rotationY += (Input.GetAxis("Mouse Y") * sensitivityY / 60 * cmra.camera.fieldOfView + offsetY);
rotationY = ClampAngle(rotationY, minimumY, maximumY);
Quaternion yQuaternion = Quaternion.AngleAxis(rotationY, Vector3.left);
transform.localRotation = originalRotation * yQuaternion;
}
}
offsetY = 0F;
offsetX = 0F;
}

void Start()
{
cmra = GameObject.FindWithTag("MainCamera");
// Make the rigid body not change rotation
if (rigidbody) { rigidbody.freezeRotation = true; }
originalRotation = transform.localRotation;
}

public static float ClampAngle(float angle, float min, float max)
{
if (angle < -360F) { angle += 360F; }
if (angle > 360F) { angle -= 360F; }
return Mathf.Clamp(angle, min, max);
}
}
```