Melonskoy, попробуйте проверить, правильно ли вы настроили ограничение камеры в Unity. Возможно, вы где-то допустили ошибку. Также, можете попробовать использовать другой метод ограничения камеры, если текущий не работает. Если вы можете предоставить больше информации о проблеме, я смогу дать более точный совет.
Melonskoy, чтобы сделать поворот игрока более плавным, можно использовать метод Lerp. Вот доработанный скрипт: using UnityEngine; public class CameraController : MonoBehaviour { public float minX = -360.0f; public float maxX = 360.0f; public float minY = -45.0f; public float maxY = 45.0f; public float sensX = 100.0f; public float sensY = 100.0f; private float rotationY = 0.0f; private float rotationX = 0.0f; public Transform player; void Start() { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } void Update() { rotationX += Input.GetAxis("Mouse X") * sensX * Time.deltaTime; rotationY += Input.GetAxis("Mouse Y") * sensY * Time.deltaTime; rotationY = Mathf.Clamp(rotationY, minY, maxY); transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0); float playerRotationY = Mathf.Lerp(player.transform.localEulerAngles.y, rotationX, Time.deltaTime * 10); player.transform.localEulerAngles = new Vector3(0, playerRotationY, 0); } } Код using UnityEngine; public class CameraController : MonoBehaviour { public float minX = -360.0f; public float maxX = 360.0f; public float minY = -45.0f; public float maxY = 45.0f; public float sensX = 100.0f; public float sensY = 100.0f; private float rotationY = 0.0f; private float rotationX = 0.0f; public Transform player; void Start() { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } void Update() { rotationX += Input.GetAxis("Mouse X") * sensX * Time.deltaTime; rotationY += Input.GetAxis("Mouse Y") * sensY * Time.deltaTime; rotationY = Mathf.Clamp(rotationY, minY, maxY); transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0); float playerRotationY = Mathf.Lerp(player.transform.localEulerAngles.y, rotationX, Time.deltaTime * 10); player.transform.localEulerAngles = new Vector3(0, playerRotationY, 0); } } В этом скрипте мы используем метод Lerp для плавного поворота игрока вокруг оси Y. Мы задаем текущий угол поворота игрока (player.transform.localEulerAngles.y), целевой угол поворота (rotationX) и скорость поворота (Time.deltaTime * 10). Таким образом, игрок будет поворачиваться более плавно и синхронно с камерой.
Вероятно, я опоздал с ответом using UnityEngine; public class CameraController : MonoBehaviour { Quaternion startRotation; float horizontal; float vertical; private void Start() { startRotation = transform.rotation; } private void Update() { horizontal += Input.GetAxis("Mouse X") * SettingsManager._sensitivity; vertical += Input.GetAxis("Mouse Y") * SettingsManager._sensitivity; horizontal = Mathf.Clamp(horizontal, -60.0f, 60.0f); // То самое ограничение vertical = Mathf.Clamp(vertical, -60.0f, 60.0f); GameObject.FindWithTag("MainCamera").transform.rotation = startRotation * transform.rotation * Quaternion.AngleAxis(-vertical, Vector3.right); transform.rotation = startRotation * Quaternion.AngleAxis(horizontal, Vector3.up); } } CSHARP using UnityEngine; public class CameraController : MonoBehaviour { Quaternion startRotation; float horizontal; float vertical; private void Start() { startRotation = transform.rotation; } private void Update() { horizontal += Input.GetAxis("Mouse X") * SettingsManager._sensitivity; vertical += Input.GetAxis("Mouse Y") * SettingsManager._sensitivity; horizontal = Mathf.Clamp(horizontal, -60.0f, 60.0f); // То самое ограничение vertical = Mathf.Clamp(vertical, -60.0f, 60.0f); GameObject.FindWithTag("MainCamera").transform.rotation = startRotation * transform.rotation * Quaternion.AngleAxis(-vertical, Vector3.right); transform.rotation = startRotation * Quaternion.AngleAxis(horizontal, Vector3.up); } }