# How can i Limit the Mouse X Axis for Mouse Look

Hello there I need to Limit the Players Rotation on the X Axis. I can Move the mouse and it will rotate the Player but i need to Stop about half way.

Here is what i got so far.

var VerticalSpeed : float = 2.0;
var HorizontalSpeed : float = 2.0;
var PlayerObject : Transform;

function Update (){
Screen.lockCursor=true;
Cursor.visible=true;
Screen.lockCursor=false;
var h : float = HorizontalSpeed *Input.GetAxis(“Mouse X”);
var v : float = VerticalSpeed *Input.GetAxis(“Mouse Y”);
transform.Rotate(-v,0,0);
PlayerObject.Rotate(0,h,0);
}

public float sensitivityX = 15F;
public float sensitivityY = 15F;

``````public float minimumX = -90F;
public float maximumX = 90F;

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

float rotationY = 0F;
float rotationX = 0f;

void Update (){
rotationX += Input.GetAxis ("Mouse X") * sensitivityX;
rotationX = Mathf.Clamp (rotationX, minimumX, maximumX);

rotationY += Input.GetAxis ("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);

transform.localEulerAngles = new Vector3 (-rotationY, rotationX, 0);
}
``````

the mathf.clamp will limit the angle of the object to the min or maximum degrees

public float sensitivityX = 15F;
public float sensitivityY = 15F;
public float minimumX = -90F;
public float maximumX = 90F;
public float minimumY = -60F;
public float maximumY = 60F;
float rotationY = 0F;
float rotationX = 0f;
void Update (){
rotationX += Input.GetAxis (“Mouse X”) * sensitivityX;
rotationX = Mathf.Clamp (rotationX, minimumX, maximumX);
rotationY += Input.GetAxis (“Mouse Y”) * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3 (-rotationY, rotationX, 0);
}