Hello i am new to unity and trying to make a fps watching a tutorial but found it difficult to understand the code it will be very thankful if anyone can help me understanding the code.
And also there is a bit weird thing happening to my game is that after i run it the camera’s rotational x is getting set to 90.
public class MouseLook : MonoBehaviour
{
public float sensitivity=100f;
public Transform playerbody;
float Xrotation=0f;
void Start()
{
Cursor.lockState=CursorLockMode.Locked;
}
void Update()
{
float mouseX=Input.GetAxis("Mouse X")*sensitivity*Time.deltaTime;
float MouseY=Input.GetAxis("Mouse Y")*sensitivity*Time.deltaTime;
Xrotation-=MouseY;
Xrotation=Mathf.Clamp(Xrotation,-90f,90f);
transform.localRotation=Quaternion.Euler(Xrotation,0f,0f);
playerbody.Rotate(Vector3.up*mouseX);
}
}