using UnityEngine; public class YawOnlyTracker : MonoBehaviour { [SerializeField] private Transform cameraTransform; public static float sensitivity = 1; public static float offset = 0; private void Start() { if (cameraTransform == null) { Debug.LogError("Камера не указана", this); return; } } public void SetConfig(PeriscopeAnglesConfig config) { sensitivity = config.sensitivity; offset = config.offset; } void LateUpdate() { Quaternion currentRotation = cameraTransform.localRotation; Vector3 eulerAngles = currentRotation.eulerAngles; // Нормализуем угол в диапазон [-180, 180] float normalizedYaw = NormalizeAngle(eulerAngles.y + offset); // Применяем sensitivity float adjustedYaw = normalizedYaw * sensitivity; // Применяем поворот (Unity сама нормализует при установке) Quaternion yawOnly = Quaternion.Euler(0f, adjustedYaw, 0f); cameraTransform.localRotation = yawOnly; } public static float NormalizeAngle(float angle) { angle %= 360f; if (angle > 180f) angle -= 360f; if (angle < -180f) angle += 360f; return angle; } }