Question by
ZalopUnity · Sep 20, 2017 at 01:51 AM ·
c#mouselook
How Do I Clamp A Rotation?
So ive been trying to do this mouselook and ive have completed the mouse look, but i cannot figure out how to make it clamp at -90 , 90. I have looked around but none fit my script, since all the others dont move with my player.
private CharacterController cc; private float vertVelocity; public float moveSpeed; public float jumpForce; private bool hasJumped = false; float moveFB; float moveLR;
public GameObject cam;
public float sens;
float rotX;
float rotY;
void Start ()
{
cc = GetComponent<CharacterController>();
}
void Update ()
{
if (Input.GetButtonDown("Jump"))
{
Jump();
}
ApplyGravity();
#region MouseLook
rotX = Input.GetAxisRaw("Mouse X") * sens;
rotY = Input.GetAxisRaw("Mouse Y") * sens;
transform.Rotate(0, rotX, 0);
cam.transform.Rotate(-rotY, 0, 0);
Comment