using CustomInspector;
using System;
using UnityEngine;
using Mirror;
using UnityEngine.InputSystem;

namespace PlayerBehaviour
{
    public class PlayerCameraController : CameraController
    {
        /// <summary>
        /// (Vertical, Horizontal)
        /// </summary>
        public readonly static Vector2 defaultLookDirection = new(25, 0);
        [SerializeField, ReadOnly, Tooltip("(Vertical, Horizontal)")]
        Vector2 lookDir = Vector2.zero;

        float MaxLookHeight => carData.PrefabSettings.maxLookHeight;
        float MinLookHeight => carData.PrefabSettings.minLookHeight;
        private float Internal_sensitivity => carData.PrefabSettings.internal_sensitivity;

        bool rotationBlocked = false;

        float currentIdle = 0;
        const float maxIdleTime = 6; //max idle time until looks forward
        const float idleMoveSpeed = 30; //when idle how fast turned to front

        private PlayerInputActions playerControls;
        private float mouseX;
        private float mouseY;

        protected override void Awake()
        {
            base.Awake();

            lookDir = defaultLookDirection;

            playerControls = new PlayerInputActions();

            // Subscribe to the actions in Awake, if the GameObject is not going to be disabled/enabled often
            playerControls.Player.Aiming.performed += OnAimPerformed;
            playerControls.Player.Aiming.canceled += OnAimCanceled;

            playerControls.Player.MouseX.performed += OnMouseXPerformed;
            playerControls.Player.MouseX.canceled += OnMouseXCanceled;

            playerControls.Player.MouseY.performed += OnMouseYPerformed;
            playerControls.Player.MouseY.canceled += OnMouseYCanceled;

        }

        public bool isAiming = false;

        private void OnAimPerformed(InputAction.CallbackContext context)
        {
            isAiming = true;

            if (!SettingsHandler.IsAimingMethodHold())
            {
                Aiming ^= true;
            }

        }
        private void OnAimCanceled(InputAction.CallbackContext context)
        {
            isAiming = false;
        }
        private void OnMouseXPerformed(InputAction.CallbackContext context)
        {
            mouseX = context.ReadValue<float>();
        }
        private void OnMouseXCanceled(InputAction.CallbackContext context)
        {
            mouseX = 0f;
        }
        private void OnMouseYPerformed(InputAction.CallbackContext context)
        {
            mouseY = context.ReadValue<float>();
        }
        private void OnMouseYCanceled(InputAction.CallbackContext context)
        {
            mouseY = 0f;
        }
        protected override void Start()
        {
            base.Start();

            if (!isLocalPlayer) return;

            rotationBlocked = true;
            Helpers.WaitSeconds(this, 0.5f, () => rotationBlocked = false);
        }

        protected override void Update()
        {
            //Base
            base.Update();

            if (!isLocalPlayer)
                return;

            //Turning
            if (InGameMouse.IsLocked // not rotate when in some kind of menu where cursor is not locked
            && !rotationBlocked)  // only start rotating a bit after the start, so user feels position before moving

            {
                // UpdateMouseInput
                float sensitivity = Internal_sensitivity * SettingsHandler.GetSensitivity() * 0.08f;
                Vector2 delta = new(-mouseY, mouseX);
                if (delta != Vector2.zero)
                {
                    lookDir += (sensitivity / currentZoom) * delta;
                    currentIdle = 0;
                }
                else
                {
                    //slowly rotate camera/view to car direction if no mouse input
                    if (carData.CameraController.Aiming)
                    {
                        currentIdle = 0;
                    }
                    else
                    {
                        var car = carData.carInstance.CarController;
                        if (car.CurrentAcceleration != Prometeo.CarController.Acceleration.Neutral) //driving
                        {
                            //begin idle when first time steered
                            if (currentIdle > 0)
                            {
                                currentIdle += Time.deltaTime;
                                if (currentIdle > maxIdleTime)
                                {
                                    lookDir = Vector2.MoveTowards(lookDir, defaultLookDirection, idleMoveSpeed * Time.deltaTime);
                                }
                            }
                            if (car.CurrentSteering != Prometeo.CarController.Steering.Straight) //if steered
                            {
                                currentIdle += Time.deltaTime;
                                //make it smallest angle
                                if (lookDir.y > 180)
                                    lookDir.y -= 360;
                                else if (lookDir.y < -180)
                                    lookDir.y += 360;
                            }
                        }
                    }

                }
                lookDir.x = Mathf.Clamp(lookDir.x, MinLookHeight, MaxLookHeight);
                lookDir.y %= 360;
            }
            LookDirection.LocalEulerAngles = lookDir;
            
            //Aiming
            if (SettingsHandler.IsAimingMethodHold())
                Aiming = isAiming;

            
        }
        private void OnEnable()
        {
            playerControls.Enable(); // Make sure to enable the input when the object is active
        }
        private void OnDisable()
        {
            // If we subscribe in Awake, we still need to disable the input when the object is not active
            playerControls.Disable();
        }
        private void OnDestroy()
        {
            if (!this.gameObject.scene.isLoaded) //whole scene was closed
                return;
        }
    }
}


I have this script for camera movement and aiming. It works, but i have now added Controller input (Right stick x and right stick y as mouseX and MouseY) but it doesnt work with controller