using System.Collections; using System.Collections.Generic; using UnityEngine; public class MouseRote : MonoBehaviour { //sensitivity => ΑιΓτΆΘ public float MouseSensitivity = 100f; public float moveSpeed=5f; private float XRotation = 0f; private float _rotationX; private bool canrote = true; // Start is called before the first frame update void Start() { Cursor.lockState = CursorLockMode.Locked; } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.LeftAlt)) { if(Cursor.lockState== CursorLockMode.Locked) { Cursor.lockState = CursorLockMode.None; canrote = false; } else if (Cursor.lockState == CursorLockMode.None) { Cursor.lockState = CursorLockMode.Locked; canrote = true; } } if (canrote) { float rotationY = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * 2; _rotationX -= Input.GetAxis("Mouse Y") * 2; _rotationX = Mathf.Clamp(_rotationX, -45, 45); transform.localEulerAngles = new Vector3(_rotationX, rotationY, 0); } } }