this is the script that i am using =
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
{
private float horizontalSensitivity = 10.0f;
private float verticalSensitivity = 10.0f;
private float v;
private float h;
private float totalV;
private float totalH;
private Quaternion tempRotation;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
// Read user input
h = horizontalSensitivity * Input.GetAxis("Mouse X");
v = verticalSensitivity * Input.GetAxis("Mouse Y");
// Accumulate total rotation from all input to date
totalV = totalV -= v;
totalH = totalH -= h;
// Calculate the single Quaternion rotation necessary to get us here
tempRotation = Quaternion.Euler(totalV, totalH, 0.0f);
// Apply that single rotation to the camera (from the origin)
transform.rotation = tempRotation;
outOfLock();
}
private void outOfLock()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
Cursor.lockState = CursorLockMode.None;
}
}
}