Mouse movement x-axis locked

Viewed 83

I'm having a problem moving my character’s mouse in particular on x-axi.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class movimentoRato : MonoBehaviour
{
    public float sensibilidade = 100f;
    public Transform playerBody;
    float xRotation = 0f;

    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
    }

    // Update is called once per frame
    void Update()
    {
        float mouseX = Input.GetAxis("Mouse X") * sensibilidade * Time.deltaTime;
        float mouseY = Input.GetAxis("Mouse Y") * sensibilidade * Time.deltaTime;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90f, 90f);

        transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
        playerBody.Rotate(Vector3.up * mouseX);
    }
}

Mouse x-axis is locked can somebody help me?

1 Answers
    float mouseX = Input.GetAxis("Mouse X") * 2.75f;
    float mouseY = Input.GetAxis("Mouse Y") * 2.75f;

    xRotation -= mouseY;
    xRotation = Mathf.Clamp(xRotation, -90f, 90f);

    transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);

    playerBody.Rotate(Vector3.up * mouseX);
Related