# Can some one explain this script to me :)

Hello guys can you please explain this script to me if it is possible i would like if you could add comments in on each line telling why they are called and what they do :). This is the mouse move script by the way :). Thank you in advance here is the script :

``````   using UnityEngine;
using System.Collections;

public class MoseMoveY : MonoBehaviour {

public enum RotationAxes { MouseY = 2 } // ??

public RotationAxes axes = RotationAxes.MouseY ;  // ??

public float sensitivityY = 15F;

public float minimumY = -360F;

public float maximumY = 360F;

Quaternion originalRotation; // ??

void Update ()
{
if (axes == RotationAxes.MouseY )// ??
{

rotationY -= Input.GetAxis("Mouse Y") * sensitivityY * Time.deltaTime;// ??

rotationY = ClampAngle (rotationY, minimumY, maximumY);// ??

Quaternion YQuaternion = Quaternion.AngleAxis (rotationY, Vector3.right);// ??

transform.localRotation = originalRotation * YQuaternion ;// ??
}

}

void Start ()
{

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);// ??
}
}

``````

See my pastebin @ http://pastebin.com/Zzh6NwPc for easy reading

`

```using UnityEngine;
using System.Collections;
public class MoseMoveY : MonoBehaviour {
```public enum RotationAxes { MouseY = 2 } // define the enum later referenced as RotationAxes.MouseY

public RotationAxes axes = RotationAxes.MouseY ;  // there are 2 axes, defined by line above

public float sensitivityY = 15F;

public float minimumY = -360F;

public float maximumY = 360F;

Quaternion originalRotation; // originalRotation is defined as a quaternion. quaternions are useful for expressing rotations.

void Update ()
{
if (axes == RotationAxes.MouseY )
{

rotationY -= Input.GetAxis("Mouse Y") * sensitivityY * Time.deltaTime;// rotation is defined by the y mouse position multiplied by sensitivity, set it to motion by multiplying it with deltaTime

rotationY = ClampAngle (rotationY, minimumY, maximumY);// limit angle using ClampAngle defined below

Quaternion YQuaternion = Quaternion.AngleAxis (rotationY, Vector3.right);// define YQuaternion

transform.localRotation = originalRotation * YQuaternion ;// manually convert originalRotation to localRotation
}

}

void Start ()
{

if (rigidbody)// if object is rigidbody
rigidbody.freezeRotation = true;// then we prevent it from rotating
originalRotation = transform.localRotation;// the originalRotation is the localRotation, when the script starts
}

public static float ClampAngle (float angle, float min, float max)// ??
{
if (angle < -360F)//
angle += 360F;// if the angle is less than -360 degrees, keep incrementing it by 360 until we get back to within boundaries. these angles are all the same
if (angle > 360F)// if the angle is more than 360 degrees, keep decreasing it by 360 until we get within boundaries. again, these are all the same, as there are only 360 degrees in a circle, and 720, and -360 are the same 0 degrees
angle -= 360F;
return Mathf.Clamp (angle, min, max);// limit angle between min and max
}

```
}
```
`