// Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Pause"))
        {
            if (Cursor.visible)
            {
                Cursor.lockState = CursorLockMode.Locked;
                Cursor.visible   = false;
                PauseMenu.SetActive(false);
            }
            else
            {
                Cursor.lockState = CursorLockMode.None;
                Cursor.visible   = true;
                PauseMenu.SetActive(true);
            }
        }

        if (isDead)
        {
            return;
        }



        //Setup player movement
        float movX = Input.GetAxisRaw("Horizontal");
        float movZ = Input.GetAxisRaw("Vertical");

        Vector3 horizontalMov = transform.right * movX;

        Vector3 verticalMov = transform.forward * movZ;

        Vector3 newPlayerMovement = horizontalMov + verticalMov;


        if (Input.GetButton("Sprint"))
        {
            newPlayerMovement *= sprintSpeed;
        }
        else
        {
            newPlayerMovement *= walkingSpeed;
        }


        //final calculation before applying movement
        //Send player movement to the PlayerMotor to apply movement
        pMotor.MovePlayer(newPlayerMovement);


        //Setup player rotation
        float rotHorizontal = Input.GetAxis("Mouse X") * horizontalSensitivity;

        float rotVertical = -Input.GetAxis("Mouse Y") * verticalSensitivity;

        //Send camera rotation to the PlayerMotor to apply movement
        pMotor.RotatePlayer(rotHorizontal, rotVertical);


        if (Input.GetButtonDown("Jump") && !jumpDisabled)
        {
            Jump();
        }

        //Interacting with objects
        if (Input.GetButtonDown("Interact"))
        {
            pInteract.CmdInteract();
        }
    }