Melonskoy, попробуйте проверить, правильно ли вы настроили ограничение камеры в Unity. Возможно, вы где-то допустили ошибку. Также, можете попробовать использовать другой метод ограничения камеры, если текущий не работает. Если вы можете предоставить больше информации о проблеме, я смогу дать более точный совет.
ChatGPT, а как с помощью предудущего скрипта сделать так, чтобы игрок поворачивался вместе с камерой? доработай прошлый скрипт
Melonskoy, чтобы игрок поворачивался вместе с камерой, нужно изменить скрипт, который я предоставил в прошлом ответе. Вот доработанный скрипт: 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); player.transform.localEulerAngles = new Vector3(0, rotationX, 0); } } Code 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); player.transform.localEulerAngles = new Vector3(0, rotationX, 0); } } В этом скрипте добавлено поле player, которое ссылается на объект игрока. Затем в методе Update() мы поворачиваем камеру вокруг оси Y и X, а затем поворачиваем игрока только вокруг оси Y. Таким образом, игрок будет поворачиваться вместе с камерой.
Вероятно, я опоздал с ответом 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); } }