Obtaining Cursor Position in First Person

I am currently working on a project that involves moving a character in first person. However, I have no idea of how to rotate the camera based on the cursor position. Can anyone help me?

(Also, if you know, how do you hide the cursor?)

When I create FPS games I move the camera using GetAxis(“Vertical”) and GetAxis(“Horizontal”).

All I do is add these 2 values to the X and Y of my camera/player.

If you want the player body to rotate along the camera on the Y axis, you would apply the Y rotation to the body, and the X rotation to the camera, so that the body follows when looking right/left, but only the camera/head moves when looking up/down.

I actually already have a MouseLook script laying around, feel free to use this:

using UnityEngine;

/// <summary>
/// Handles the player looking.
/// </summary>
public class PlayerLook : MonoBehaviour {

    private Camera playerViewCamera;

    [Header("Look Settings")]
    public bool AllowLook = true;
    public Vector2 LookSensitivity;
    private float maxLookXRestriction;
    private float minLookXRestriction;

    private GameObject playerBody;
    private Vector2 mouseInput;

	private void Awake()
        playerViewCamera = transform.GetChild(0).GetComponent<Camera>();
        playerBody = gameObject;
	private void Update()
        mouseInput.x =  Input.GetAxis("Mouse X") * LookSensitivity.x;
        mouseInput.y = -Input.GetAxis("Mouse Y") * LookSensitivity.y;

        if (AllowLook)
            playerBody.transform.Rotate(0, mouseInput.x, 0);
            playerViewCamera.transform.Rotate(mouseInput.y, 0, 0);
            playerViewCamera.transform.rotation = Quaternion.Euler(playerViewCamera.transform.eulerAngles.x, playerViewCamera.transform.eulerAngles.y, 0);

            if (playerViewCamera.transform.rotation.x > maxLookXRestriction)
                playerViewCamera.transform.rotation = new Quaternion(Quaternion.Euler(maxLookXRestriction, 0, 0).x, playerViewCamera.transform.rotation.y, playerViewCamera.transform.rotation.z, playerViewCamera.transform.rotation.w);
            else if (playerViewCamera.transform.rotation.x < minLookXRestriction)
                playerViewCamera.transform.rotation = new Quaternion(Quaternion.Euler(minLookXRestriction, 0, 0).x, playerViewCamera.transform.rotation.y, playerViewCamera.transform.rotation.z, playerViewCamera.transform.rotation.w);

And in order to show/or hide your Cursor, the Cursor.visible and Cursor.lockState properties can be used like this:

            Cursor.lockState = CursorLockMode.None;
            Cursor.visible = true;

That will unlock the cursor and show it, and the code under will lock the cursor to the game window and hide it:

            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible = false;